重新启动 - 计算机访问被拒绝错误

时间:2017-09-29 15:34:04

标签: powershell

我目前正在创建一个需要能够重命名计算机名称的PowerShell脚本:

Write-Host "Enter the new computer name: " -NoNewline
$name = Read-Host
Rename-Computer -NewName $name

当我执行此代码时,我收到此错误,即使我使用管理员权限启动脚本,我也会收到同样的错误。

  

重命名 - 计算机:计算机" LAPTOP-ASVDNCPD"无法重命名为" [new_computer_name]"由于以下异常:拒绝访问。

1 个答案:

答案 0 :(得分:0)

您需要自我提升脚本以管理员身份运行命令。 PowerShell: Running a command as Administrator

相关问题