Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The term 'Rename-Computer' is not recognized as the name of a cmdlet

Tags:

powershell

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
like image 323
We Rub Chan Avatar asked Jan 22 '26 23:01

We Rub Chan


2 Answers

That's because Rename-Computer was introduced in Powershell 3.0

like image 130
Kohlbrr Avatar answered Jan 25 '26 15:01

Kohlbrr


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.

like image 31
Adi Inbar Avatar answered Jan 25 '26 13:01

Adi Inbar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!