Solved

Run .VBS file as Admin on a list of servers

Posted on 2016-08-18
5
28 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

632 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