 |
 |
 |
| One step further - PowerShell script to modify multiple users' property in Active Directory |
 |
|
|
By: Ying Li
Posted On: 9/14/2007
In my previous script, I showed how we can add or modify the user properties in Active Directory for single user. Now as a by request script, I will go one step further and try to do the same thing for multiple users. The trick is you need to have a csv file ready and the import-csv cmdlet.
This article was Previously posted on Ying Li's Blog
I have a sample users.csv file and it looks like this:
DN Telephonenumber CN=UserA,OU=X,OU=Y,OU=Z,DC=what,DC=ever,DC=com xxx-yyy-zzz CN=UserB,OU=A,OU=B,OU=C,DC=what,DC=ever,DC=com aaa-bbb-ccc CN=UserC,OU=L,OU=M,OU=N,DC=what,DC=ever,DC=com lll-mmm-nnn
Once you have the csv file ready – you could run the below script against it (You need to have the approriate right to your domain!)
$users = import-csv users.csv foreach($row in $users) { $dn = $row.dn $user=[ADSI]"LDAP://$dn" $tel = $row.telephonenumber $user.put("telephoneNumber", $tel) $user.SetInfo() }
You could change the Telephonenumber to EmployeeID or whatever fields you are interested at and it can target as many users as you want. Of course, test it in a small scale first!
|
 |
 |
 |
|