服务器加入域后无法重新启动



早上好,

我遇到了一个问题,我有一个脚本将服务器连接到域并重新启动,保留它的角色/功能等,然后再次重新启动它。我对第一次重启没有问题:

Restart-Computer -ComputerName $IP -Credential $AdminCred -Wait -For PowerShell

但当我试图在脚本结束时进行第二次重新启动时,它会出现以下错误

Restart-Computer : The computer is skipped. Fail to retrieve its LastBootUpTime via the WMI service with the
following error message: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

以下是我尝试的原始代码

Restart-Computer -ComputerName $HostName -Wait -For PowerShell

没有凭据,因为我希望Kerberos能够工作,因为笔记本电脑上的帐户具有适当的权限

但我也用CCD_ 1和同样的错误运行了它。然后我尝试将$HostName更改为$IP,但仍然没有成功。

我可以通过将Restart-Computer命令封装到invoke-command会话中来绕过错误;等待powershell";除非我设置了一个任意的睡眠定时器几分钟。

欢迎提出任何想法!

我想明白了。我必须添加-WsmanAuthentication参数并指定Kerberos。最终代码

Restart-Computer -ComputerName $HostName -WsmanAuthentication Kerberos -Wait -For PowerShell

相关内容

最新更新