I want to rename the computer with PowerShell 2.0 in Windows 7 Sp1, but it got an error.
PS C:\Windows\system32> Rename-Computer -NewName PC02
The term 'Rename-Computer' is not recognized as the name of a cmdlet, function, script f
ile, or operable program. Check the spelling of the name, or if a path was included, ver
ify that the path is correct and try again.
At line:1 char:16
+ Rename-Computer <<<< -NewName PC02
+ CategoryInfo : ObjectNotFound: (Rename-Computer:String) [], CommandNotFo
undException
+ FullyQualifiedErrorId : CommandNotFoundException
That's because Rename-Computer was introduced in Powershell 3.0
To do this in PowerShell 2.0, use WMI:
(Get-WmiObject Win32_ComputerSystem).Rename('PC02')
You can rename a remote computer by adding -ComputerName CURRENTNAME after Get-WmiObject.
You must do this from an elevated prompt. This will, of course, require a reboot to take effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With