General discussion

Locked

Renaming multiple computer accounts

By kenni39 ·
We may need to rename 4000+ Computer accounts, whilst retaining multiple profiles on each workstation, in our W2K3 AD structure. This is to enable UUIDs for a TS printing solution. Anyone have any advice on the best way to do this. CSVDE, LDIFDE, .vbs ? Anyone had to do this? Any help gratefully received

This conversation is currently closed to new comments.

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

All Comments

Collapse -

A possible solution

by jambazz In reply to Renaming 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 IT Employment Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums