Searching AD for a specific attribute using the get-aduser function from the ActiveDirectory PowerShell module.
First the ActiveDirectory module needs to be loaded. You can check to see if the module is available by typing:
Get-Module -listavailable
If you don’t see the ActiveDirectory module you will need to download the RSAT.
To load the module type:
Import-Module ActiveDirectory
Search for a specific attribute:
# Searches the entire directory Get-ADUser -Filter * -Properties * | Where {$_.physicalDeliveryOfficeName -ne "Whatever" # To set all users who don't have "Whatever" in their Office attribute Get-ADUser -Filter * -Properties * | Where {$_.physicalDeliveryOfficeName -ne "Whatever" | set-aduser -office "SomethingElse"