This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Invoke-RestMethod -Uri https://codeconverter.net/csharp/powershell -Method Post -Body @{ | |
Content="class MyClass { void Delete() { var item = new Object(); } }" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var connectionObject = new LdapConnection(new LdapDirectoryIdentifier(controller), new NetworkCredential(username, password)); | |
var directoryAttributeModification = new DirectoryAttributeModification(); | |
directoryAttributeModification.Name = attribute; | |
directoryAttributeModification.Operation = DirectoryAttributeOperation.Delete; | |
var response = connectionObject.SendRequest(new ModifyRequest | |
{ | |
DistinguishedName = dn, | |
Modifications = | |
{ | |
directoryAttributeModification |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var connectionObject = new LdapConnection(new LdapDirectoryIdentifier(controller), new NetworkCredential(username, password)); | |
var directoryAttributeModification = new DirectoryAttributeModification(); | |
directoryAttributeModification.Name = attribute; | |
directoryAttributeModification.Operation = DirectoryAttributeOperation.Replace; | |
foreach (var value in values) | |
{ | |
if (value is byte[]) | |
{ | |
directoryAttributeModification.Add(value as byte[]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var connectionObject = new LdapConnection(new LdapDirectoryIdentifier(controller), new NetworkCredential(username, password)); | |
var directoryAttributeModification = new DirectoryAttributeModification(); | |
directoryAttributeModification.Name = "doGarbageCollection"; | |
directoryAttributeModification.Operation = DirectoryAttributeOperation.Add; | |
directoryAttributeModification.Add("1"); | |
connectionObject.SendRequest(new ModifyRequest | |
{ | |
DistinguishedName = "", | |
Modifications = | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var connectionObject = new LdapConnection(new LdapDirectoryIdentifier(controller), new NetworkCredential(username, password)); | |
var request = new ModifyDNRequest | |
{ | |
DeleteOldRdn = true, | |
DistinguishedName = dn, | |
NewName = "CN=" + newCn | |
}; | |
var response = connectionObject.SendRequest(request); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param($Configuration) | |
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent | |
mkdir $PSScriptRoot\package -ErrorAction SilentlyContinue | Out-Null | |
mkdir $PSScriptRoot\package\lib -ErrorAction SilentlyContinue | Out-Null | |
mkdir $PSScriptRoot\package\content -ErrorAction SilentlyContinue | Out-Null | |
Copy-Item "$PSScriptRoot\bin\$Configuration\*.DLL" $PSScriptRoot\package\lib -Force | |
Copy-Item "$PSScriptRoot\bin\$Configuration\*.key" $PSScriptRoot\package\content -Force |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<package> | |
<metadata> | |
<id>MyProject</id> | |
<version>1.0</version> | |
<title>$title$</title> | |
<authors>Adam Driscoll</authors> | |
<owners>ARD</owners> | |
<requireLicenseAcceptance>false</requireLicenseAcceptance> | |
<description>NuGet Package for my .NET Assemblies</description> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void CreateProcessAsUser(string applicationName, string commandLine, string username, string domainName, string password) | |
{ | |
var si = new STARTUPINFO(); | |
var pi = new PROCESS_INFORMATION(); | |
if (!CreateProcessWithLogonW(username, domainName, password, | |
LogonFlags.LOGON_NETCREDENTIALS_ONLY, null, applicationName + " " + commandLine, | |
CreationFlags.CREATE_DEFAULT_ERROR_MODE, 0, null, ref si, out pi)) | |
{ | |
throw new Win32Exception(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type " | |
public class MyClass { | |
public string MyString {get;set;} | |
public object GetNull { get { return null; } } | |
public void SetNull() { MyString = null; } | |
}" | |
$myObject = New-Object -TypeName MyClass | |
$myObject.MyString = "Hey!" | |
$myObject.MyString = $null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CreateProfile | |
{ | |
param([String]$pszUserSid, [String]$pszUserName, [System.Text.StringBuilder]$pszProfilePath, [uint]$cchProfilePath) | |
Add-Type -TypeDefinition ' | |
using System; | |
using System.Runtime.InteropServices; | |
public static class PInvoke { | |
[DllImport("userenv.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
public static extern int CreateProfile( [MarshalAs(UnmanagedType.LPWStr)] String pszUserSid, [MarshalAs(UnmanagedType.LPWStr)] String pszUserName, [Out, MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszProfilePath, uint cchProfilePath); | |
} |