To rename a bunch of computers in a domain, first create a list of the old names and the new names in a file, separating them with commas. You'll need a header row, and then each old/new pair in their own row, like this:


Save the file as "rename.csv" to a known location such as C:\temp.
Warning: trailing spaces in the csv file will cause failure, as will extra spaces between the old name and the comma.

Create a PowerShell script to rename them, let's call it "new-name.ps1", and save it in the same location:
# Script to rename computers in a domain by parsing a CSV file 
# Assumes: File of names with a header row of OldName,NewName
# and a row for oldname,newname pairs for each computer to be renamed.
# Adjust filename and file path as appropriate. 
$csvfile = "C:\temp\rename.csv"
Import-Csv $csvfile | foreach { 
$oldName = $_.OldName;
$newName = $_.NewName;
Write-Host "Renaming computer from: $oldName to: $newName"
netdom renamecomputer $oldName /newName:$newName /uD:example\username /passwordD:* /force /reboot

Obviously you'll want to replace the domain username with the correct one for your environment. This will prompt you for the domain password for each netdom command. You could easily expand on this by prompting the user once at the start of the script for the password, and saving it in a variable.

The beauty of this for me, as an old system administrator, is that it uses a new way (PowerShell) to do an everyday thing, but builds on my old knowledge (netdom, which surely goes back to the days of MS LanManager).

Other Languages