PowerShell: Query All Domain Controllers for Blank Attributes in Active Directory

Query all domain controllers for users with a blank “mail” attribute and if the user is enabled/disabled, then export a CSV list for each user that is found. Replace “mail” with whatever attribute you would like to query.

Get-ADDomainController -Filter * | ForEach-Object {echo $_.Name; Get-ADObject -Server $_.Name -LDAPfilter '(mail=\20)' | ForEach-Object {Get-ADUser $_.distinguishedname | Select-Object -Property Name,enabled } | export-csv blankmanager-$_.Name.csv }

Leave a comment

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