[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2007-10-08
17
Medium Priority
?
868 Views
Last Modified: 2013-12-28
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
0
Comment
Question by:hpbrucewong
  • 10
  • 7
17 Comments
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 20038429
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
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 20038444
Using 'PSShutdown' you will only have to schedule following statement:

PSShutdown @Computers.txt -f -k
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 20038473
If you are interested in .vbs script then have a look at following

http://redmondmag.com/columns/article.asp?EditorialsID=692
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:hpbrucewong
ID: 20038820
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
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 20038871
It works perfectly at my end. Make sure "Windows Management Instrumentation" service is Enabled and Running (both Server & Client end).
0
 

Author Comment

by:hpbrucewong
ID: 20039025
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
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 20039050
Do you have Windows Firewall (or any other firewall) Enabled? Can please try to disable that and then check.
0
 
LVL 26

Accepted Solution

by:
Farhan Kazi earned 1000 total points
ID: 20039206
OK Try following statement, it will shutdown all systems that are listed inside Clients.txt file.

Click Start -> Run -> Cmd.exe

WMIC /NODE:@"C:\Clients.txt" OS WHERE Primary=1 CALL Shutdown
0
 

Author Comment

by:hpbrucewong
ID: 20039358
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"
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 20039481

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
0
 

Author Comment

by:hpbrucewong
ID: 20039501
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!
0
 

Author Comment

by:hpbrucewong
ID: 20039570

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

"

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

Expert Comment

by:Farhan Kazi
ID: 20039581

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
0
 

Author Comment

by:hpbrucewong
ID: 20039661
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?
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 20039758

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              







0
 

Author Comment

by:hpbrucewong
ID: 20046179
"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.
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 20046254

Thats great, Thanks allot.
0

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Server 2003 introduced persistent Volume Shadow Copies and made 2003 a must-do upgrade.  Since then, it's been a must-implement feature for all servers doing any kind of file sharing.
Unable to change the program that handles the scan event from a network attached Canon/Brother printer/scanner. This means you'll always have to choose which program handles this action, e.g. ControlCenter4 (in the case of a Brother).
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question