Solved

Run .VBS file as Admin on a list of servers

Posted on 2016-08-18
5
26 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 25

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 25

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

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
A brief introduction to what I consider to be the best editor for PowerShell.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

820 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