I was having a conversation with a colleague today and the subject of remotely shutting down windows servers and desktops came up. This is something that we as Virtualisation people tend not to have to do any more, well we do have direct access to the console in vCenter, and we can issue the remote command via the vCenter too. But what about those physical servers that are left scattered about the place
Well this is an oldie but maybe something you have forgotten about.
We all know about the Windows Command Shutdown, however what about the “i” option; the Shutdown /i command allows the remote shutting down of Windows machines. What is even better about this is that it also allows correct annotation of the remote machines eventlog.
To Utilise the Windows interface, yes there is a Windows interface to Shutdown :D, as the command shutdown is a CLI command, the Remote Shutdown dialog box can be displayed only by typing shutdown /i at a command prompt.
1. Open Command Prompt and type
shutdown /i to display the Remote Shutdown dialog box (Shutdown.exe).
2. Under Computers, click Add to enter computer names, or click Browse to open the Find Computers dialog box.
3. Under What do you want these computers to do, click Restart or Shutdown.
4. If you did not anticipate restarting or shutting down the target computers at this time, clear the Planned check box.
5. Select the appropriate reason from the list.
6. If a comment is required, the OK button will not function until you type at least one character one in the text box. This is very similar to the dialog box displayed when attempting to interactively shutdown a server.“Now for those of you with a really short memory to open a command prompt, click Start, point to All programs, point to Accessories, and then click Command prompt.”
Another thing to remember is that to carry out this procedure, you must have the necessary user rights to force a shutdown from a remote system. At the minimum you require “Force shutdown from a remote system“. For a list of security groups that have this permission by default , see “Privileges”
Now to use this as part of a script or just to hardcore from the command line:
1. Open Command Prompt and type:
shutdown /s /m \\ComputerName/d 1:1 this will initiate an unplanned shutdown after a default wait period of 30 seconds, with the major reason, Hardware, and the minor reason, Maintenance.
Or alteratively type:
shutdown /r /m \\ComputerName/t 60 /d p:4:2 this restart will be consided a planned and will commence a minute after the command is issued, with the major reason, Application, and the minor reason, Installation.
|/s||Shuts down the computer.|
|/r||Restarts the computer after shutdown.|
|/m \\ComputerName||Specifies the target computer.|
|/t nnn||Sets the wait period before a restart or shutdown to nnn seconds, causing a warning to display on the local console.
You can specify from 0 through 600 seconds.
If you omit /t, the wait period defaults to 30 seconds.
|/d[p:]xx:yy||Lists the reason for the system restart, shutdown, or power off. The following rows describe the parameter values.|
|p:||Indicates that the restart or shutdown is planned. If you do not use the p: option, Shutdown Event Tracker assumes that the restart or shutdown is unplanned.|
|xx||Specifies the major reason number (from 0 through 255).|
|yy||Specifies the minor reason number (from 0 through 65535).|
For the complete command line syntax, see “Shutdown“.
Hope that this has refreshed everybodies memory like it has mine.