Skip to content

Instantly share code, notes, and snippets.

@rycuda
Created October 5, 2015 10:39
Show Gist options
  • Save rycuda/b167adc2bb23fcc21792 to your computer and use it in GitHub Desktop.
Save rycuda/b167adc2bb23fcc21792 to your computer and use it in GitHub Desktop.
Powershell to spit out stale (enabled) users and stale computers.
Search-ADAccount -ComputersOnly -AccountInactive -timespan 30.00:00:00 | sort name | ft name,distinguishedname
Search-ADAccount -UsersOnly -AccountInactive -timespan 30.00:00:00 | Get-ADUser | Where-Object {$_.enabled} | sort name | ft name,distinguishedname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment