POWERSHELL ACTIVE DIRECTORY BULK USER SCRIPTS

Powershell Active Directory Bulk User Scripts

set email address for each user retrieved from csv file HR_Update.csv:

 Name,Email
 Mehmet Senm,msen@company.com
 John Doe,jdoe@company.com
 Jessica Hopkins,jhopkins@company.com

Filter and get each name that matches name in csv file and re-set the email for that user again from csv file (be careful when copy paste the single quotation ‘

Import-CSV .\emailu.csv | ForEach-Object {Get-ADUser -Filter “Name -eq ‘”$($_.Name)`”” | Set-ADUser -EmailAddress $_.Email}

 

search for a specific user

PS C:\Users\msen> Get-ADUser -Filter ‘UserPrincipalName -like “msen@na.edu”‘ -SearchBase ‘ou=NAU,dc=na,dc=edu’ -Properties proxyaddresses | Select-object UserPrincipalName, proxyaddresses

UserPrincipalName proxyaddresses
 ----------------- --------------
 msen@na.edu {SMTP:msen@na.edu, x500:/o=ExchangeLabs/ou=Exchange Admi...

 

To list all users

PS C:\Users\msen> Get-ADUser -Filter ‘UserPrincipalName -like “msen@na.edu”‘ -SearchBase ‘ou=NAU,dc=na,dc=edu’ -Properties proxyaddresses | Select-object UserPrincipalName, proxyaddresses

UserPrincipalName proxyaddresses
 ----------------- --------------
 msen@na.edu {SMTP:msen@na.edu, x500:/o=ExchangeLabs/ou=Exchange Admi...

 

Add new ProxyAdress Attribute Value

PS C:\Windows\system32> Get-ADUser -Filter ‘UserPrincipalName -like “msen@na.edu”‘ -SearchBase ‘ou=NAU,dc=na,dc=edu’ -Properties proxyaddresses | Foreach {Set-ADUser -identity $_ -Add @{‘ProxyAddresses’=@(“SMTP:{0}” -f $_.UserPrincipalName)}}

 

list users according to the department group: BA_UNDER -> BA -> Dept -> NAU

PS C:\Windows\system32> Get-ADUser -Filter * -SearchBase ‘ou=BA_Under,ou=BA,ou=Dept,ou=NAU,dc=na,dc=edu’ -Properties proxyaddresses | Select-object UserPrincipalName, proxyaddresses

 

Let’s update all users’ proxy addresses

PS C:\Windows\system32> Get-ADUser -Filter * -SearchBase ‘ou=NAU,dc=na,dc=edu’ -Properties proxyaddresses | Foreach {Set-ADUser -identity $_ -Add @{‘ProxyAddresses’=@(“SMTP:{0}” -f $_.UserPrincipalName)}}

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