PowerShell – ActiveDirectory Searches

Cool stuff. Get every AD User Object that has an E-mail message attribute assigned:

Import-Module ActiveDirectory
Get-ADObject -Filter {(mail -like "*") -and (ObjectClass -eq "user")} -Server CORP:3268


Import-Module ActiveDirectory
Get-ADObject -Filter {(mail -like "*") -and (ObjectClass -eq "user")} -Server CORP:3268


Import-Module ActiveDirectory
Get-ADUser -Filter {(SamAccountName -like "*" -and (mailNickName -like "*")} `
| Set-ADUser -Replace @{extensionAttribute1='FoundAttribute1';extensionAttribute2='FoundAttribute2';}

Reference URLs:
http://technet.microsoft.com/en-us/library/ee617198.aspx
http://technet.microsoft.com/en-us/library/dd772723(WS.10).aspx

Extra:

Get-Command -Module *
Get-Command -Module CimCmdlets
Get-Command -Module ActiveDirectory

Advertisements