+ Post New Thread
Results 1 to 7 of 7
Windows Server 2008 R2 Thread, Active Dirctory User Names in Technical; Hi Everyone, any idea if i can bulk swap surname and firstname in AD ? When uploading CSV's to setup ...
  1. #1

    Join Date
    Jun 2010
    Location
    Cardiff
    Posts
    79
    Thank Post
    35
    Thanked 3 Times in 3 Posts
    Rep Power
    10

    Active Dirctory User Names

    Hi Everyone,

    any idea if i can bulk swap surname and firstname in AD ?

    When uploading CSV's to setup our users in the sumer i rushed it (never a good idea) and consiquently some users now show surname in the firstname field and first name in the surname field.

    Any whay i can change this without doing it all again ?

    Many thanks

  2. #2
    Duke5A's Avatar
    Join Date
    Jul 2010
    Posts
    859
    Thank Post
    88
    Thanked 154 Times in 124 Posts
    Blog Entries
    8
    Rep Power
    36
    Code:
    Set oContainer = GetObject("LDAP://OU=Staff,OU=Users LPS,DC=domain,DC=com")
    oContainer.Filter = Array("user")
    
    For Each User in oContainer
    
    	on error resume next
    
    	strOldSN = User.SN
    	strOldFN = User.FirstName
    	
    	User.SN = strOldFN
    	User.FirstName = strOldSN
    	User.FullName = strOldSN & Chr(32) & strOldFN
    
    	User.SetInfo
    
    	wscript.sleep (100)
    
    	If err.number <> 0 Then
    		msgbox "Error: " & strOldSN
    	end if
    Next
    Change the LDAP path to match the OU you want to run it in. You need to isolate the users though that have their names flipped (you would have to do this regardless of what scripted solution you use). I hope this helps.

  3. #3

    Join Date
    Jun 2010
    Location
    Cardiff
    Posts
    79
    Thank Post
    35
    Thanked 3 Times in 3 Posts
    Rep Power
    10
    Hi thank you for your help.

    I have set the script as below (xxx is where i put my domain name etc

    Set oContainer = GetObject("LDAP://OU=Intake2004,OU=Students,OU=xxxxxxx Users,DC=xxxxx,DC=xxxxxxxx")
    oContainer.Filter = Array("user")

    For Each User in oContainer

    on error resume next

    strOldSN = User.SN
    strOldFN = User.FirstName

    User.SN = strOldFN
    User.FirstName = strOldSN
    User.FullName = strOldSN & Chr(32) & strOldFN

    User.SetInfo

    wscript.sleep (100)

    If err.number <> 0 Then
    msgbox "Error: " & strOldSN
    end if
    Next

    when i run the vbs nothing seems to happen.

    do i need to add anything else ?

    Many thanks

  4. #4

    Join Date
    Mar 2007
    Posts
    1,861
    Thank Post
    93
    Thanked 326 Times in 246 Posts
    Rep Power
    92
    Wisesoft ad managment will do this in s spreadsheet for you.

  5. Thanks to strawberry from:

    richbrowncardiff (5th February 2013)

  6. #5

    Join Date
    Jun 2010
    Location
    Cardiff
    Posts
    79
    Thank Post
    35
    Thanked 3 Times in 3 Posts
    Rep Power
    10
    Many thanks !

    I forgot about wisesoft perfect.

  7. #6
    Duke5A's Avatar
    Join Date
    Jul 2010
    Posts
    859
    Thank Post
    88
    Thanked 154 Times in 124 Posts
    Blog Entries
    8
    Rep Power
    36
    I guess it would be nice to know when it was done processing an OU. Check your users. If you didn't see a message box in initial run then it flipped the names. If you ran it a second time then it would flip the names again.

    Code:
    Set oContainer = GetObject("LDAP://OU=Staff,OU=Users LPS,DC=domain,DC=com")
    oContainer.Filter = Array("user")
    
    For Each User in oContainer
    
    	on error resume next
    
    	strOldSN = User.SN
    	strOldFN = User.FirstName
    	
    	User.SN = strOldFN
    	User.FirstName = strOldSN
    	User.FullName = strOldSN & Chr(32) & strOldFN
    
    	User.SetInfo
    
    	wscript.sleep (100)
    
    	If err.number <> 0 Then
    		msgbox "Error: " & strOldSN
    	end if
    Next
    
    Msgbox "Work is done!"

  8. #7
    enjay's Avatar
    Join Date
    Apr 2007
    Location
    Reading, Berkshire, UK
    Posts
    4,497
    Thank Post
    282
    Thanked 196 Times in 167 Posts
    Rep Power
    76
    WiseSoft Bulk AD Users - download all your AD users into a CSV, edit the CSV and then upload it back again. I used this recently when I needed to change everyone's surname, also to remove email addresses from lots of users at once.



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: 14
    Last Post: 17th August 2012, 05:20 PM
  3. Replies: 4
    Last Post: 20th January 2009, 10:02 PM
  4. Replies: 2
    Last Post: 30th January 2007, 11:27 PM
  5. Replies: 3
    Last Post: 16th November 2006, 10:55 PM

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
  •