Just today my wonderful colleague showed me a great way to restart machine and at the same time – test if it has came up and is operational (basically if PowerShell responds remotely).
Restart-Computer -ComputerName <COMPUTERNAME> -Wait -Protocol wsman -force
Use -force to forcely logoff any active sessions (savage!!!!)
After performing restart in above way, console waits and will not go further, unless PS on the remote machine responds!
Isn’t that cool!?