+ Post New Thread
Results 1 to 4 of 4
Windows Server 2000/2003 Thread, Adding and changing user properties in Technical; Is there a way of quickly population the "First Name and Last Name" fields in Active directory, for example importing ...
  1. #1

    Join Date
    Sep 2007
    Posts
    177
    Thank Post
    4
    Thanked 2 Times in 2 Posts
    Rep Power
    9

    Adding and changing user properties

    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!

  2. #2
    fawkers's Avatar
    Join Date
    Jun 2007
    Location
    Southend
    Posts
    190
    Blog Entries
    2
    Thank Post
    32
    Thanked 21 Times in 20 Posts
    Rep Power
    26
    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

    Code:
    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

  3. #3

    john's Avatar
    Join Date
    Sep 2005
    Location
    Yorkshire
    Posts
    9,092
    Thank Post
    960
    Thanked 719 Times in 639 Posts
    Rep Power
    195
    I use this - http://www.wisesoft.co.uk/software/b...s/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

  4. #4
    browolf's Avatar
    Join Date
    Jun 2005
    Location
    Mars
    Posts
    1,364
    Blog Entries
    36
    Thank Post
    73
    Thanked 76 Times in 63 Posts
    Rep Power
    30
    Quote Originally Posted by jwood View Post
    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.

    Code:
    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

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 7
    Last Post: 13th May 2009, 06:54 PM
  2. Properties of Drive
    By Chuckster in forum Windows
    Replies: 7
    Last Post: 29th April 2009, 09:59 AM
  3. Printer properties
    By cookie_monster in forum Windows
    Replies: 7
    Last Post: 23rd July 2008, 04:13 PM
  4. System Properties
    By JAW$ in forum Windows
    Replies: 5
    Last Post: 7th March 2008, 12:43 AM
  5. Adding User Name To Print Jobs
    By Richie_OLSJ in forum Network and Classroom Management
    Replies: 11
    Last Post: 8th June 2007, 11:55 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •