How to bulk rename active directory user objects

I need to rename active directory user objects. For example the user account is called ai1 and the first name, last name and display name is Albert Einstein. I need the user account to be seen as Albert Einstein. I also need to do this for hundreds of account all at once.

Does anyone have any solutions.
LVL 1
Colin_A_MoulderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shift-3Commented:
Paste the script below into a text file with a .cmd extension.  Customize the value of the root variable on line 4 with the distinguished name of the domain or OU to search under.  Running the script on a 2003 server or XP workstation with the adminpak installed will echo DSMOVE commands to rename each user to the value of their Display Name.

Once you have tested it successfully and are sure it will do what you intend, remove the word ECHO from line 12 to execute the commands.


@echo off
setlocal enabledelayedexpansion
 
set root=ou=Accounting,DC=yourdomain,dc=local
 
for /F "tokens=*" %%G in ('dsquery user "%root%" -limit 0 ^| dsget user -dn -display -L') do (
 set line=%%G
 if "!line:~0,3!"=="dn:" set dn=!line:~4!
 
 if "!line:~0,8!"=="display:" if "!line:~9!" NEQ "" (
  set display=!line:~9!
  ECHO dsmove "!dn!" -newname "!display!" -q
 )
)
 
pause

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Networking

From novice to tech pro — start learning today.