VBScript to Shutdown Remote Windows 2003 Servers

I am a domain admin for a large enterprise environment.  We are moving our data center and I need a script to shutdown Windows 2000 and 2003 servers remotely.  Since some of the servers will need to be taken down prior to the bulk and some after the bulk I would like to find a vbscript that will allow me to use a txt file to list which servers I want the shutdown command to run on.  
I usually create a batch file to run the VBScript so it will run in a DOS window instead of issuing pop-up messages.  I have approx 500 servers I will need to shut down.  I honestly do not want to have to create a messy batch file to issue the shutdown /m \\computername code for all 500 servers.  That would take way to long.  If someone can help me I would really appreciate it.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Here's a batch file which take a text file input.
Heres another option which allows you to specify user name and password of the user which will issue the shutdown command

Curteousy of a technet magazine article (I forget the author - if your reading this...sorry!)
Dim oFSO, oTS, sClient, oWindows, oLocator, oConnection, oSys
Dim sUser, sPassword

'set remote credentials
sUser = "Administrator"
sPassword = "password"

'open list of client names
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTS = oFSO.OpenTextFile("C:\clients.txt")

Do Until oTS.AtEndOfStream
 'get next client name
 sClient = oTS.ReadLine
 'get WMI locator
 Set oLocator = CreateObject("WbemScripting.SWbemLocator")

 'Connect to remote WMI
 Set oConnection = oLocator.ConnectServer(sClient, _
   "root\cimv2", sUser, sPassword)

  'issue shutdown to OS
 ' 4 = force logoff
 ' 5 = force shutdown
 ' 6 = force rebooot
 ' 12 = force power off
 Set oWindows = oConnection.ExecQuery("Select " & _
   "Name From Win32_OperatingSystem")
 For Each oSys In oWindows


'close the text file
WScript.Echo "All done!"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DrScott35Author Commented:
The script works however, I do not like having to save my Domain Admin Password in a Clear Text text file.  Is there a way I can run this using my logged in credentials?  Also, I would like to have it dispaly which server it is attempting to shutdown for example:

All Done!
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Thats fair enough - My scripting abilities arent the best (like I said - thats simply copied from a technet article from a good few years ago)

One option could be to create a non-"domain admin" user that has rights to shutdown computers...But of course there is an inherant security risk with that too.

But it should be relatively easy to rework and just use the credentials of the currently logged on user (i.e. you when you run the script)

And all we would need to do is simply echo to screen which server it is currently doing - although, its a vbs script so would run very fast, and just issue all of the shutdown commands to every server in the list in one go, so all you would get is a repeat of the servers in your text file.
Im guessing you would prefer it to echo out wether the server has accepted the command or not?

I'll go and have a dig about on the net to see what I can find - but Im sure someone else may come up with the goods first ;)


How about the ShutdownRestart tool? http://redmondmag.com/columns/article.asp?EditorialsID=1385

You can target all the machines in an OU, text file or list using this quite easily and force to shutdown, restart, logoff and power-off remotely.

Have a look.
DrScott35Author Commented:

Thanks for the article.  The link to download the program did not work inside the article but after doing a little web searching I was able to find the correct script.  Here's the address for anyone that follows:  http://www.computerperformance.co.uk/ezine/BestPractice/BestPractice97.htm .  I have not tested it since I'm just going to use the before mentioned code.  I did some tweaking to it this afternoon.  
If it works the way the article describes I'm sure it would be a very useful utility.
DrScott35Author Commented:
Thank you for your help Paul.  I'm going to use this script for now but I'm still looking for a better alternative for the future.  Thanks again for you help with this.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.