Grab our RSS feeds Follow us on Twitter Join our Facebook Group Connect with us on LinkedIn
myITforum.com, Powered by You.
you are not logged in

Articles

Newslinks

Links

Downloads

Site Services

Community Forums

Discussion Lists

Article Search

Newsletter

Web Blogs

FAQs

Live Support

myITforum TV

Take a Poll

Monthly Drawing

myITforum Network

User Group Directory

Our Partners

About Us

Register

Login

BRONZE PARTNER:

BRONZE PARTNER:



Industry News:




  Home : Articles : Windows PowerShell print | email | | Forums |   print | email | | Blogs |   print | email | | Wiki |   print | email | | FAQs |   print | email | Article Search  
One step further - PowerShell script to modify multiple users' property in Active Directory


Bookmark and Share

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!


  myITforum.com ©2010 | Legal | Privacy