Best Practice Ezine #97 Shutdown
Thank you Paul DeBrino for sending in today’s scripts. I would also like to thank David Klein and others for sending in utilities which I will feature in a later ezine.
Paul sent me instructions for two utilities, each has distinct characteristics, both are concerned with shutting down machines, therefore be careful with machine names.
I have previously featured shutdown in Ezine 45. The idea is to restart or power-off a remote machine. In my opinion, nobody can become expert with shutdown until you shoot yourself in the foot and down your own machine unintentionally. Once that happens you imprint in your brain this abort command:
In many ways Paul’s shutdown -i removes the need for such caution because his switch provides a GUI, hence less scope for mistakes. Over to Paul.
The Windows Shutdown.exe utility is truly awesome for shutting down and restarting even remote computers. If you run Shutdown -i you’ll be working with a nice graphical user interface (see below) where you can specify multiple computers. Copy and paste names from a text file, for example, and you can reboot an entire Web farm with just a few clicks. If you use it entirely from the command-line, however, you can’t give Shutdown.exe a list of computer names or have it grab names from an Active Directory organizational unit (OU). This limits its usefulness in some scenarios.
What we have with Shutdownrestart.wsf is a script which you download and install on your machine. Once again, the purpose is to shutdown remote machines, but the killer advantage is the scripts pings a list of machine names that you store in a text file. If ping is successful then, depending on your commands, the script shuts down, powers-off or restarts that machine. You can even persuade the script to report machines it could not ping successfully. Over to Paul:
You can give it a list of computers, specify an action (which must be shutdown, restart, logoff or poweroff) and even have the tool force that action (thus forcing applications to close, if necessary). For example Run
However, instead of /list, try specifying /container (e.g. /container:Sales) which will target every computer account in your domain’s Sales OU. You can also specify the /log argument, as in /log:C:\failed.txt. This will create a log file named C:\failed.txt, which includes the names of all the computers that the tool was asked to target, but couldn’t reach. That creates a list of machines you’ll need to deal with manually, or you can make some adjustments and feed the list back to the tool using the /list argument.
Note that the /action:poweroff option can only work on computers whose motherboards specifically implement a Windows-commanded power-down. Most new systems do this. If your systems don’t, Windows will just quit to the "It’s now safe to power down your system" screen without actually shutting down.
1) Download the Windows Script File: shutdownrestart is inside col6.zip If you have trouble with the zip, try here.
2) Open a command window.
3) Run the shutdownrestart command with appropriate arguments.
4) Start with shutdownrestart /?
Examples of shutdownrestart
1) shutdownrestart /list:computers.txt /ping /verbose /action:restart /force
2) shutdownrestart /container:sales /ping /verbose /action:restart /force
3) shutdownrestart /container:sales /ping /verbose /action:restart /force /log:C:\temp\failed.txt
It was a humbling experience for Guy try someone else’s script, I fell into all the usual trap of not paying attention to detail, for example I typed shutdownrestart /list :computers.txt. The mistake is a space between /list and the colon : it should be tight, /list:computers.txt.
Technically you can run shutdownrestart in a pure command line environment with cscript.exe. The programme explains how to switch to the command line version with ‘run cscript //h:cscript’. However, I stayed with WScript GUI version of shutdownrestart.
Have you noticed how rock stars are in fact frustrated sportsmen, while sportsmen all want to be rock stars? Even within sportsmen all runners really want to be footballers. I find there is a similar effect in computing, here am I a minor expert in Windows who would love to explore Cisco.
Lots of useful Windows shutdown and hibernate articles