Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Run .VBS file as Admin on a list of servers

Posted on 2016-08-18
5
Medium Priority
?
32 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 2000 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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

718 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