Skip to content

Instantly share code, notes, and snippets.

@mczerniawski
Created December 7, 2018 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mczerniawski/fd15c15d27fc2541da012df53ddf8598 to your computer and use it in GitHub Desktop.
Save mczerniawski/fd15c15d27fc2541da012df53ddf8598 to your computer and use it in GitHub Desktop.
$userOUs = @('OU=Leavers,OU=Site1,OU=Contoso Users,DC=Contoso,DC=com','OU=Leavers,OU=Site2,OU=Contoso Users,DC=Contoso,DC=com')
$disabledUsers = foreach ($ou in $userOUs) {
get-aduser -filter {Enabled -eq $false} -SearchBase $ou
}
$disabledUsers | Export-Csv -Path C:\AdminTools\disabled_users.csv -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment