Question : 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.

Answer : How to bulk rename active directory user objects

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.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
@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
Random Solutions  
 
programming4us programming4us