Shut Down, Already
Use this script to shut down or reboot a group of computers.
I never tire of scripts and utilities that can shut down or restart Windows
systems en masse. They're useful during scheduled maintenance windows, for shutting
down client computers for weekends or holidays (think of the power you'll save)
or for running on your very last day of work just for fun (just kidding -- I
don't condone that in any way).
The Windows Shutdown.exe utility is truly awesome for shutting down and restarting
even remote computers. Run Shutdown -i and you'll
be working with a nice graphical user interface (see Figure 1) 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.
Enter my custom tool of the month: ShutdownRestart. 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). Run shutdownrestart /list:computers.txt
/ping /verbose /action:restart /force, for example, and you'll get the
output shown in Figure 2 as the specified computers dutifully reboot themselves.
[Click on image for larger view.]
|Figure 1. The GUI for Windows
Shutdown.exe is solid, but somewhat limited.
That's not all. Instead of /list, you can specify
/container, as in /container:Sales,
which will target every computer account in your domain's Sales OU (they always
forget to shut down for the weekend, don't they?). 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 or for
which it didn't have sufficient permissions. 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
[Click on image for larger view.]
|Figure 2. The resulting output
of this month's shutdown script.
Hopefully this tool will give you some additional control over your environment,
and make the next mass-restart or mass-shutdown of a group of computers just
a bit easier for you.
With more than fifteen years of IT experience, Don Jones is one of the world’s leading experts on the Microsoft business technology platform. He’s the author of more than 35 books, including Windows PowerShell: TFM, Windows Administrator’s Scripting Toolkit, VBScript WMI and ADSI Unleashed, PHP-Nuke Garage, Special Edition Using Commerce Server 2002, Definitive Guide to SQL Server Performance Optimization, and many more. Don is a top-rated and in-demand speaker and serves on the advisory board for TechMentor. He is an accomplished IT journalist with features and monthly columns in Microsoft TechNet Magazine, Redmond Magazine, and on Web sites such as TechTarget and MCPMag.com. Don is also a multiple-year recipient of Microsoft’s prestigious Most Valuable Professional (MVP) Award, and is the Editor-in-Chief for Realtime Publishers.