术语“重命名 - 计算机”'不被识别为cmdlet的名称

时间:2014-04-16 20:21:04

标签: powershell

我想在Windows 7 Sp1中使用PowerShell 2.0重命名计算机,但是出现错误。

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

2 个答案:

答案 0 :(得分:5)

那是因为Rename-Computer是在Powershell 3.0中引入的

答案 1 :(得分:2)

要在PowerShell 2.0中执行此操作,请使用WMI:

(Get-WmiObject Win32_ComputerSystem).Rename('PC02')

您可以在 Get-WmiObject 之后添加-ComputerName CURRENTNAME来重命名远程计算机。

您必须从提升的提示中执行此操作。当然,这需要重启才能生效。