13 November 2017

Ldap filter to recursively find all groups a user is member


Get-ADGroup -LDAPFilter "(member:1.2.840.113556.1.4.1941:=CN=Uservane,OU=Users,DC=domain,DC=local)"

15 February 2017

Search for expiring domain accounts


Search-ADAccount -AccountExpiring -TimeSpan "365" 

16 January 2017

Keyboard shortcuts for Powershell console

Ctrl + End - delete all text after the cursor
Ctrl + Home - delete all text before the cursor

29 December 2016

Dispose COM objects as it can cause memory leaks

# dispose COM objects as it can cause memory leaks
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($VariableName) | Out-Null

15 December 2016

Calculate MD5 with powershell


[Reflection.Assembly]::LoadWithPartialName("System.Web")
[System.Web.Security.FormsAuthentication]::HashPasswordForStoringInConfigFile("p@ssw0rd", "MD5")