Some documentation refers to the Rename-Computer cmdlet, but according to this post, providing an invalid computer name could cause unexpected results. Since local and remote computers can already be renamed using WMI and netdom.exe, the cmdlet was removed. There is some documentation out there indicating the Rename method will not work on domain members, but I have tested this technique on Windows 7 and XP systems in a domain.
Get-WmiObject Win32_ComputerSystem -ComputerName OLDNAME -Authentication 6 |
ForEach-Object {$_.Rename("NEWNAME","PASSWORD","USERNAME")}
The password can be masked using Get-Credential.
$credential = Get-Credential
Get-WmiObject Win32_ComputerSystem -ComputerName OLDNAME -Authentication 6 |
ForEach-Object {$_.Rename("NEWNAME",$credential.GetNetworkCredential().Password,$credential.Username)}
The system needs to be rebooted for the change to take effect.
Get-WmiObject Win32_OperatingSystem -ComputerName OLDNAME |
ForEach-Object {$_.Win32Shutdown(6)}