AnnDroyd Posted November 18, 2009 Posted November 18, 2009 Is there a way of quickly population the "First Name and Last Name" fields in Active directory, for example importing from a csv file, or a command line option? At present, our students only have a username and display name specified, but we wish to add their real names to help staff locate their email address through the Outlook Address book. With nearly 2000 students, we need a better method than simply typing them all in from a list!
fawkers Posted November 18, 2009 Posted November 18, 2009 HI This might be just the thing your looking for Dsmod user if you've got a csv file with there username, forename and surname this bit of powershell from our script here might help you out function get-dn ([string]$SAMName,[string]$type) { $root = [ADSI]'' $searcher = new-object System.DirectoryServices.DirectorySearcher($root) if($type.Contains("group")){ $searcher.filter = "(&(objectClass=group)(cn= $SAMName))" } else{ $searcher.filter = "(&(objectClass=user)(sAMAccountName= $SAMName))" } $user = $searcher.findall() if ($user.count -gt 1){ $count = 0 foreach($i in $user){ write-host $count ": " $i.path $count = $count + 1 } $selection = Read-Host "Please select item: " return $user[$selection].path.toString() } else{ return $user[0].path } } Import-Csv c:\somefile.csv | ForEach-Object{ $userDN = get-dn $_.username dsmod user $UserDN.substring(7) -fn $_.Forename -ln $_.Surname -display ($_.Forename + " " + $_.Surname) } Hope this Helps .Adam
john Posted November 18, 2009 Posted November 18, 2009 I use this - http://www.wisesoft.co.uk/software/bulkadusers/default.aspx from Wisesoft, great tool I used it to update loads of fields from MIS Exports this summer just gone in our AD and its another great free tool from them
browolf Posted November 18, 2009 Posted November 18, 2009 Is there a way of quickly population the "First Name and Last Name" fields in Active directory, for example importing from a csv file, or a command line option? At present, our students only have a username and display name specified, but we wish to add their real names to help staff locate their email address through the Outlook Address book. With nearly 2000 students, we need a better method than simply typing them all in from a list! I wrote a script to do something like this the other week, mine reads the display name, chops it up and puts it back into the first/last name fields. It would be simple to modify to read from a file instead. Set colItems = GetObject _ ("LDAP://OU=pupils,DC=domain,DC=xxx,DC=xx") colitems.filter = Array("user") on error resume next For Each objuser in colItems err.clear ltest = objuser.lastname if err.number <> 0 then wscript.echo "fixing ->" & objuser.displayname namearray = split(objuser.displayname," ") zfirstname = namearray(0) zsurname = namearray(1) objuser.firstname = zfirstname objuser.lastname = zsurname objuser.setinfo wscript.echo "Done: " & objuser.firstname & " " & objuser.lastname end if Next
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now