I have a scenario where I need to reboot a computer twice, remotely. My command:
Invoke-Command -ComputerName $computerName -Credential $cred -ScriptBlock {
workflow Reboot {
Restart-Computer -Wait
Restart-Computer -Wait
}
Reboot
}
But this returns the error
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