Powershell Stuff


to disable all users not logged in for 90 days, and move them in to a new ou

$90Days = (get-date).adddays(-90)

Get-ADUser -SearchBase “DC=test,DC=LOCAL” -filter {lastlogondate -le $90days -AND passwordlastset -le $90days} -Properties lastlogondate, passwordlastset | set-aduser -Description (get-date).toshortdatestring()

Get-ADUser -SearchBase “DC=test,DC=LOCAL” -filter {lastlogondate -le $90days -AND passwordlastset -le $90days} -Properties lastlogondate, passwordlastset | set-aduser -Description ((get-date).toshortdatestring()) –passthru | Disable-ADAccount

Get-ADUser -SearchBase “DC=test,DC=LOCAL” -filter {lastlogondate -le $90days -AND passwordlastset -le $90days} -Properties lastlogondate, passwordlastset | MOVE-adobject -TargetPath “OU=Disabled,DC=test,DC=local”

Leave a Reply

Your email address will not be published. Required fields are marked *