Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 术语';重命名计算机';未识别为cmdlet的名称_Powershell - Fatal编程技术网

Powershell 术语';重命名计算机';未识别为cmdlet的名称

Powershell 术语';重命名计算机';未识别为cmdlet的名称,powershell,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,

我想在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
PS C:\Windows\system32>重命名计算机-NewName PC02
术语“重命名计算机”无法识别为cmdlet、函数、脚本f的名称
ile或可操作程序。检查名称的拼写,或者如果包含路径,请检查版本
请确认路径正确,然后重试。
第1行字符:16

+重命名计算机这是因为Powershell 3.0中引入了
重命名计算机
要在Powershell 2.0中执行此操作,请使用WMI:

(获取WmiObject Win32\u ComputerSystem)。重命名('PC02')
您可以通过在获取WmiObject之后添加
-ComputerName CURRENTNAME
来重命名远程计算机


您必须在提升的提示符下执行此操作。当然,这需要重新启动才能生效。

那么我该怎么做,将Powershell升级到3.0或使用2.0中的其他cmdlet可以做到这一点?@WeRubChan如果你想使用
重命名计算机
,你需要升级到v3(如果可能,我建议升级)。否则是在v2中重命名的方法。可以在PowerShell 2中使用WMI进行重命名。请参阅我刚才添加的答案。@AdiInbar我知道-这就是为什么我在之前的评论中包含了使用WMI的方法。