Solved

Run .VBS file as Admin on a list of servers

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

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 23

Expert Comment

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Hi all.   The other day I had to change the passwords for a bunch of users on the fly. Because they were so many, I decided to do it in an automated way and I would like to share it with you all.   If you are not doing it directly in a Domain Co…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

708 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

12 Experts available now in Live!

Get 1:1 Help Now