Mr. Roboto
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
shutting down.
[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.
About the Author
Don Jones is a multiple-year recipient of Microsoft’s MVP Award, and is Curriculum Director for IT Pro Content for video training company Pluralsight. Don is also a co-founder and President of PowerShell.org, a community dedicated to Microsoft’s Windows PowerShell technology. Don has more than two decades of experience in the IT industry, and specializes in the Microsoft business technology platform. He’s the author of more than 50 technology books, an accomplished IT journalist, and a sought-after speaker and instructor at conferences worldwide. Reach Don on Twitter at @concentratedDon, or on Facebook at Facebook.com/ConcentratedDon.