Renaming domain computers via PowerShell *Update*

Master Blaster

[H]ard|Gawd
Joined
Nov 23, 2006
Messages
1,442
So, I have the following script, set to run in PS. The goal is to rename our current domain machines on the network via the CSV file.

# 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
}



Currently, PS has been enabled to run scripts from my machine, but it throws the "not a recognized cmdlet" error when netdom is run. I've read that netdom has been removed from Windows 7 - so what would be the command to replace this?

**UPDATE**

This script is working correctly inside PowersShell IDE, yet not inside PowerShell command-line.

Any help or suggestions would be great. Thanks.
 
Last edited:
Back
Top