Unfortunately in Windows, we often need to reboot for various reasons, whether that be installing patches, software etc. When we do this remotely, it is a waiting and guessing game to know when your machine(s) are up back up. Fortunately, if you use PowerShell for rebooting, we can know for sure with Restart-Computer.

In this example, I want to reboot the computer “testmachine1”. In the Restart-Computer command, I use the -For parameter to indicate that I want powershell to be available remotely via WMI before returning to my prompt. I specify¬†-timeout and -wait to wait 10 minutes for the machine to reboot and be ready again. I also use -Force to reboot even if another user is logged on.

Click the gif below to play:




Art Pufford · January 26, 2018 at 11:49 am

I’m pretty new to Powershell. How do you get the countdown timer under “VERBOSE: Performing the operation “Enable the Remote shutdown access rights and restart the computer.”
on target “XXXXXXXXX”.” When I run the command, it reboots the server and then just sits there with nothing on the screen until the computer is back up. That is fine but having the counter would be nice. Thank you…..

    Dan Franciscus · January 26, 2018 at 11:52 am

    Hmm. What version of PowerShell are you using? I did not do anything special outside of running that exact command.

    Matthew Davidson · January 26, 2018 at 2:48 pm

    Hi Art…this could be due to the version of powershell you are using.

Matthew Davidson · January 26, 2018 at 3:06 pm

Really handy line of code too….it works very well when you reboot a system remotely and the remote software needs to load up before you can reconnect. Thanks for the great tip Dan!

    Dan Franciscus · January 26, 2018 at 3:07 pm

    Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *