+ 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
    181
    Thank Post
    4
    Thanked 2 Times in 2 Posts
    Rep Power
    15

    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
    193
    Thank Post
    32
    Thanked 22 Times in 21 Posts
    Blog Entries
    2
    Rep Power
    32
    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
    London
    Posts
    10,422
    Thank Post
    1,531
    Thanked 1,066 Times in 931 Posts
    Rep Power
    305
    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,533
    Thank Post
    108
    Thanked 89 Times in 75 Posts
    Blog Entries
    47
    Rep Power
    41
    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. Adding User Name To Print Jobs
    By Richie1972 in forum Network and Classroom Management
    Replies: 20
    Last Post: 26th August 2014, 05:54 PM
  2. Replies: 7
    Last Post: 13th May 2009, 06:54 PM
  3. Properties of Drive
    By Chuckster in forum Windows
    Replies: 7
    Last Post: 29th April 2009, 09:59 AM
  4. Printer properties
    By cookie_monster in forum Windows
    Replies: 7
    Last Post: 23rd July 2008, 04:13 PM
  5. System Properties
    By JAW$ in forum Windows
    Replies: 5
    Last Post: 7th March 2008, 12:43 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
  •