Solved

Run .VBS file as Admin on a list of servers

Posted on 2016-08-18
5
19 Views
Last Modified: 2016-10-17
I have a .vbs file located on same drive and path ex: D:\Check\Check.vbs
Normally we need to login to every server and run this file to perform a monthly server health check
This time I am trying to use a powershell script to run this file on all 20 servers with out logging in to it
Currently we login and open command prompt as admin and go to the drive and path to execute the file as admin
Any help is much appreciated with a script
0
Comment
Question by:PavanPA
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Benjamin Voglar
ID: 41760786
1
 

Author Comment

by:PavanPA
ID: 41763367
I cannot run a windows scheduler cause we do not know when will the maintenance complete. Only after its completed and the server is restarted we try to run this vbs to see if any errors are there...
0
 
LVL 24

Accepted Solution

by:
Coralon earned 500 total points (awarded by participants)
ID: 41819005
There are plenty of ways to do this..

1. Copy the vbs file to all of the servers in the same location..

Option1 - (Requires the Admin shares available)
for /f %f in (serverlist.txt) do psexec -h \\servername cscript //i <localpathtoscript>

Open in new window


Option2 - (Requires that your servers allow powershell scripts *and* powershell remoting
get-content .\serverlist.txt | foreach-object { invoke-command -computername $_ -scriptblock { & cscript.exe //i <path>\script.vbs }
}

Open in new window


Either of those should do exactly what you want..

On a side note.. you could set up scheduled tasks to run your vbscript and just modify your script check for a file, or a registry key, etc.  Then your script would just delete the check when it completes.. but those 2 solutions will work just fine for you :-)

Coralon
0
 
LVL 24

Expert Comment

by:Coralon
ID: 41846287
Solutions provided are appropriate for the question posed.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now