Active Directory Shell – One Liners

Locked Accounts
Search-ADAccount -LockedOut | Get-ADUser -Properties * | ?{$_.LockedOut -eq $True} | select name, samaccountname, LockedOut, AccountLockouttime

DHCP Scopes with High Utilization (70% or more)
“Server1”, “Server2” | %{Get-DhcpServerv4ScopeStatistics -ComputerName $_ | ?{$_.percentageinuse -gt 70} | sort percentageinuse | select ScopeId, Free, PercentageInUse }

Mass Disable
Get-Content myListOfSamAccountNames.txt | Get-ADUser  | Disable-ADAccount

Mass Move
Get-Content myListofDNs.txt | Get-ADObject | Move-ADObject -TargetPAth “OU=My,OU=Path,DC=domain,dC-com”