Monday, May 18, 2009

Powershell Reboot

Ever need to reboot a server remotely, and no standard tools (shutdown, etc) are working?

Can't RDP the box or get to it any other way?

I discovered a little trick about a year and a half ago, and it has been saving my life, and those of my colleagues ever since.  I just actually had to use it, which reminded me that I ought to post it.

$server = gwmi win32_operatingsystem -computer USSERVER1
$server.reboot()

Performing this will provide you with some output.  As long as it comes back with an output of zero, you are good to go.  I believe the target server doesn't even need powershell installed; just the one you are using to reboot it.


No comments: