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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s