Change E-Mail address to Users in Specific OU.


here tricky one.

i have huge amount of users specific ou need new e-mail address.

from user1@mail.com user1@mail2.com

the web full of answers problem rely on 1 thing
: “active directory web services”

in environment off need go around get-aduser , find way of getting list of users attribute ou=… , of users, change e-mail address from… ….

until had :

function get-aduser( [string]$samid=$env:username){      $searcher=new-object directoryservices.directorysearcher      $searcher.filter="(&(objectcategory=person)(objectclass=user)(samaccountname=$samid))"      $user=$searcher.findone()       if ($user -ne $null ){           $user.getdirectoryentry()      } } $user = get-aduser "testuser" $user.psbase.displayname(users diplay name) $user.psbase.propertyname $user.psbase.mail $user.mail = 'test05@mail.com' $user.setinfo() write-host "changed attributes $user.name" $user.mail

honestly don`t know came , when because have long time now. thing doesn`t search users in entire ad have specific attibute ou=useroutest.

also, please correct mistakes find in code , understand i`m not expert. patient... :)

thank all.


hi,

i think easiest way users email details into a csv file

you need download quest powershell commandlets (they free) http://www.quest.com/powershell/activeroles-server.aspx

then open csv in excel or notepad , change email address - can find , replace. once done, can import csv in updating email address field - may need update proxyaddresses field - if let me know can give code that.

get-qaduser -searchroot "ou=ou-where-the-users-are,dc=domainname,dc=domainname" | export-csv c:\temp\usersemail.csv
import-csv c:\temp\usersemail.csv | foreach { 	set-qaduser $_.userprincipalname -email $_.mail 	}
  

denis cooper mcitp ea - mct



Windows Server  >  Directory Services



Comments

Popular posts from this blog

DCOM received error "2147746132" from...

DFSR RPC replication errors 5014 1726 with large files over VPN

ADFS 3.0 Event ID 4625 | An Error occurred During Logon | Status: 0xC000035B