richbrowncardiff Posted February 5, 2013 Posted February 5, 2013 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
Duke5A Posted February 5, 2013 Posted February 5, 2013 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.
richbrowncardiff Posted February 5, 2013 Author Posted February 5, 2013 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
strawberry Posted February 5, 2013 Posted February 5, 2013 Wisesoft ad managment will do this in s spreadsheet for you. 1
richbrowncardiff Posted February 5, 2013 Author Posted February 5, 2013 Many thanks ! I forgot about wisesoft perfect.
Duke5A Posted February 6, 2013 Posted February 6, 2013 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. 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!"
enjay Posted February 7, 2013 Posted February 7, 2013 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.
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