Test this with a few entries in the csv before you run it against all 10k.
$AllComputers = import-csv -Path C:\temp\Computers.csv
$User = "NyDomain\Myadmin"
$PWord = ConvertTo-SecureString -String "myadminpassword" -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
foreach ($Computer in $AllComputers) {
Rename-Computer -ComputerName $Computer.oldname -NewName $Computer.newname -DomainCredential $Credential -force
}
If your PC's respond to a ping, then you might want to use a version that has more error handling. Some of your pc's will be shut off, so you will likely need to run the script multiple times. You could also regenerate the csv with names that got missed.
$AllComputers = import-csv -Path C:\temp\Computers.csv
$User = "NyDomain\Myadmin"
$PWord = ConvertTo-SecureString -String "myadminpassword" -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
foreach ($Computer in $AllComputers) {
$ping = Test-NetConnection -ComputerName $computer.oldname -ErrorAction Stop -WarningAction SilentlyContinue
if ($ping.PingSucceeded) {
try {
Rename-Computer -ComputerName $Computer.oldname -NewName $Computer.newname -DomainCredential $Credential -force -ErrorAction Stop
"{0} successfully renamed to {1}" -f $Computer.oldname, $Computer.newname
} catch {
"Unable to rename {0}, Error={1}" -f $Computer.oldname,$_
}
} else {
"Unable to ping {0}" -f $Computer.oldname
}
}