Link to home
Start Free TrialLog in
Avatar of hpbrucewong
hpbrucewong

asked on

What Should I Do to Shut down All Workstations at a Scheduled Time via Active Directory?

Im asked to come up with a solution that shuts down approximate 200 PCs with a script via Microsoft Active Directory at a scheduled time. Lets say 12:00 a.m. Can anybody to provide with a script that does just that?

Any help would be appreciated!

Regards,

Bruce Wong
Avatar of Farhan Kazi
Farhan Kazi
Flag of Australia image

Greetings Bruce Wong,

You can make batch to remote shutdown PC's and schedule it.
Put all your computer names that you want to shutdown inside Computers.txt file.

:: BATCH SCRIPT START
@ECHO OFF
FOR /F %%c IN ('Type Computers.txt') DO Shutdown /m \\%%c /s /f
EXIT /B /0
:: BATCH SCRIPT END

2nd method is to use PSShutdown (comes with PSTools) utility. In PSShutdown you can specify this list of computers or a file having all computer names.

For more info:
http://www.microsoft.com/technet/sysinternals/utilities/psshutdown.mspx

Hope this helps!
Farhan
Using 'PSShutdown' you will only have to schedule following statement:

PSShutdown @Computers.txt -f -k
If you are interested in .vbs script then have a look at following

http://redmondmag.com/columns/article.asp?EditorialsID=692
Avatar of hpbrucewong
hpbrucewong

ASKER

The  Remote Shutdown  VBScript is a very "tasty" attempt to shut down all workstations simultaneously. I'm very grateful for helping me out But, unfortunately, I encountered an error when I ran it for the first time, second time, third time and goes on, the screen shot reads like the attachment.


Attachment: http://img240.imageshack.us/img240/9516/vbserrordb2.png
It works perfectly at my end. Make sure "Windows Management Instrumentation" service is Enabled and Running (both Server & Client end).
But by default the Windows XP the WMI service is started automatically like the screenshot below.

Screenshot: http://img240.imageshack.us/img240/4592/vbserror02uz8.png
Do you have Windows Firewall (or any other firewall) Enabled? Can please try to disable that and then check.
ASKER CERTIFIED SOLUTION
Avatar of Farhan Kazi
Farhan Kazi
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That works for me like a magic, but the only gotcha is that I can't force shut it down. Any ideas?
Say something like "shutdown.exe -s /f"

Thanks for the points, try following statement it will Forcefully Shutdown & Power Off

WMIC /NODE:@"Clients.txt" OS WHERE Primary=1 CALL Win32Shutdown 12

Farhan
Thanks, dude, your help is very much appreciated!
PS: Can you shed some light on the extra commands since I want to learn more about it.

Huge thanks!

"
WMIC /NODE:@"Clients.txt" OS WHERE Primary=1 CALL Win32Shutdown 12

"

This one doesn't work on my machines. Why?

Do you receive any error? Can you please post the output that you get from above command.

WMIC /NODE:@"Clients.txt" OS WHERE Primary=1 CALL Win32Shutdown 5

4   = Force Logoff
5   = Force Shutdown
6   = Force Rebooot
12 = Force Power Off
No error msg occured. Command ran successfully without forcely shutting computer down. But when I ran the previous command (WMIC /NODE:@"Clients.txt" OS WHERE Primary=1 CALL Win32Shutdown 12) which shuts down computer perfectly.

Anything wrong with the last command, Farhan?

You mean Win32Shutdown with 5 is working and shutting down Windows but does not power off?

Instead of giving file name try giving individual system name. Try following on few systems.

WMIC /NODE:"ComputerNameHere" OS WHERE Primary=1 CALL Win32Shutdown 12
                                    ^--- Computer Name Here              

WMIC /NODE:"ComputerNameHere" OS WHERE Primary="TRUE" CALL Win32Shutdown 12
                                    ^--- Computer Name Here              







"WMIC /NODE:@"C:\Clients.txt" OS WHERE Primary="TRUE" call Win32Shutdown 5" works great for me.
It's been so kind of you all the way, farhankazi . If anything I can help you, just ask.

Thats great, Thanks allot.