I was recently surprised by how many seasoned IT Pros didn’t know that they had the ability to shut down a server or workstation from the command line using the SHUTDOWN command. Not only is it possible to shut down the local machine from the command line, but it is also possible to shutdown other machines on your domain as well.
Why is this important?
This is useful in many ways. Utilizing the command line shutdown routine, you can now script shutdowns or reboots of systems. If you have ever run Exchange or SQL, then you know they will take as much memory as possible to use as cache. While this makes your SQL or Exchange server perform better, the only way to get these systems to release memory is by rebooting. By using the SHUTDOWN command from the command line you can choose when to reboot your servers to reduce user downtime.
I have used this method many times to gracefully shutdown hung servers. As I’m sure you’re aware, shutting down a server gracefully is always preferable to taking it down hard by holding in the power button for 10 seconds. Taking a DC (domain controller) or SQL server down hard oftentimes leads to corruption (which sometimes isn’t noticed until years later).
How does it work?
First launch an administrative command prompt. For instructions on launching an administrative command prompt see my prior post titled How to Open the Command Prompt in Windows 7/Vista with Administrative Rights. From an administrative command prompt you have several combinations (type SHUTDOWN /? to see all options for the SHUTDOWN command). Here are a few examples to get you started:
The following will reboot the server with a five minute fuse. The “/R” switch indicates a reboot instead of a shutdown. The “/T” switch indicates the time in seconds until the reboot. When this line is executed all users with a desktop session on this system will get a notification that the server will shutdown. On some systems users will even get a countdown showing how long they have until the system is restarted.
SHUTDOWN /R /T 300
The following command will shutdown the server immediately. The “/S” switch indicates you wish to shutdown the server instead of rebooting. The “/T 0” switch indicates time in seconds. Since zero seconds is indicated, the system will process the shutdown immediately.
SHUTDOWN /S /T 0
This example will reboot a server on the network named SERVER1. The “/F” switch will force the shutdown regardless of any open applications or services. This is often helpful for hung or stubborn servers. The “/M \\SERVER1” switch indicates which remote machine will execute the command (in this case SERVER1).
SHUTDOWN /F /R /M \\SERVER1 /T 0