General discussion

Locked

Changing Multiple Computer Account names

By kenni39 ·
We may need to rename in excess of 4000+ Computer accounts in our W2K3 AD structure shortly. Can anyone recommend best practice for this? DSMOD, CSVDE, LDIFDE, scripting. Any advice gratefully accepted

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by jambazz In reply to Changing Multiple Compute ...

Hi, I used this script to rename +250 pc's from random names to a prefix+the last part of their original names. The script runs on the local pc, renames the pc and renames the account in AD, you will immediately see the change in the computername, but a reboot is needed afterwards.:

Set WshNetwork = CreateObject("WScript.Network")
Dim Prefix, Suffix, CurrentName, NewName
Prefix = "XXX-" 'You don't need this.
CurrentName = WshNetwork.ComputerName 'Returns the name of the pc
Suffix = Right(CurrentName, 3) 'Returns the last 3 chars from CurrentName
NewName = Prefix & Suffix 'The new name consists of 2 strings, Prefix and Suffix
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & CurrentName & "\root\cimv2")

Set colComputers = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")

For Each objComputer in colComputers
err = objComputer.Rename(NewName) 'Renames the account to that of NewName
Next

In order to make this work, I made a usergroup in AD to which I delegated these specific rights:
Join a Computer to the Domain.
Full control of Computer Policy objects.
Full control of Computer objects.
My domain users were made a part of this temporary group, and the script above ran as a login script. After the renaming of all the computers I deleted the temporary group. In order for this script to work the users have to either be local admins or the script has to run as an administrator.
Best regards!

Back to Windows Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums