我有一种情况,我需要重新启动计算机两次,远程。 我的命令:
Invoke-Command -ComputerName $computerName -Credential $cred -ScriptBlock {
workflow Reboot {
Restart-Computer -Wait
Restart-Computer -Wait
}
Reboot
}
但是,这将返回错误
Failed to restart the computer com1 with the following error message: A system shutdown is in progress.
+ CategoryInfo : OperationStopped: (com1:String) [Restart-Computer], InvalidOperationException
+ FullyQualifiedErrorId : RestartcomputerFailed,Microsoft.PowerShell.Commands.RestartComputerCommand
+ PSComputerName : com1