header image

Waiting for restart

Posted by: | February 25, 2014 | No Comment |

Some times you need to reboot a remote machine as part of your process.  PowerShell provides the Restart-Computer cmdlet to perform that task:

Restart-Computer -ComputerName server03

If you want you process to pause until the reboot has finished then you add the –Wait parameter:

Restart-Computer -ComputerName server03

You final options when pausing are to wait until a specific service – PowerShell, WinRM or WMI is avialable:

Restart-Computer -ComputerName server03 -Wait -For PowerShell

Restart-Computer -ComputerName server03 -Wait -For WinRM

Restart-Computer -ComputerName server03 -Wait -For Wmi

These options should cover most situations as these services are among the last to become available when a machine starts.

under: PowerShell Basics