need a script to run form my workstation a script form the file server

Aamer M
Aamer M used Ask the Experts™
on
I want to copy the application installation file or a vbs script on a share created on a file server.

on my workstation I want to have a text file with computer names in txt or csv format.

want to use a tool like psexec that executes a command on the remote computer

run the application or the vbs file on all the computers listed in the text file.

clients are windows 7 sp1

appreciate help
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
AlexSenior Infrastructure Analyst

Commented:
You're going to need to give us more information, saying you want a script doesn't tell us what you want it to do.

Author

Commented:
on my workstation I will have a list of computer names in a text file or csv file on which I want to install some windows updates and IE11.

i want to store all the update files and the IE files on a file share: \\FS1\Share1\abc.vbs

i want from my computer to use a tool like psexec thal will take names from the text file and remotely run the vbs script to install the updates and ie on the client computers.

I run the psexec command from my workstation that should pick names from the text file and run the command to run the script on the client computers
AlexSenior Infrastructure Analyst

Commented:
Seems a bit like a pain.


$Computers = Get-Content "Enter conputers here"
ForEach ($Computer in $Computers) {
	If (Test-Connection -ComputerName $Computer -Quiet) {
		& PSEXEC "\\$($Computer)" Enter psexec command
	} Else {
		"$($Computer) is not online" | Out-File -Append "C:\temp\compsnotline.txt"
	}
}

Open in new window

Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

Author

Commented:
is there a better way for this.

there are 500 computers on which I want to remotely run a script stored on a file server. any suggestion will be very helpfull
AlexSenior Infrastructure Analyst

Commented:
$Computers = Get-Content "c:\temp\listofcomputers.txt"
ForEach ($Computer in $Computers) {
	If (Test-Connection -ComputerName $Computer -Quiet) {
		& PSEXEC "\\$($Computer)" Enter psexec command
	} Else {
		"$($Computer) is not online" | Out-File -Append "C:\temp\compsnotline.txt"
	}
}

Open in new window


That's where you enter your Text file.

Author

Commented:
the command I want to run is

\\filesrv1\shared\script\script1.vbs or

\\filesrv1\shared\script\script1.bat

the psexec syntax is like this

psexec @computers.txt /accepteula -u "Domain\User" -p "password" -i 2 -d cmd.exe /c

this has to run using an elevated user.

I am really bad with scripts and help appreciated
kevinhsiehNetwork Engineer

Commented:
If you have 500 machines, you should have WSUS in your environment at the very least, or maybe System Center Configuration Manager. You can manage all Microsoft updates via WSUS.

Author

Commented:
is an secure network and internet connectivity is not allowed. we download updates offline. put it in a share. make a script file to run the apps.

I know this is a very tiring process. but have no option
AlexSenior Infrastructure Analyst

Commented:
$Computers = Get-Content "c:\temp\listofcomputers.txt"
ForEach ($Computer in $Computers) {
	If (Test-Connection -ComputerName $Computer -Quiet) {
		& PSEXEC.exe "\\$($Computer)" /accepteula -u "Domain\User" -p "password" -i 2 -d \\filesrv1\shared\script\script1.bat
	} Else {
		"$($Computer) is not online" | Out-File -Append "C:\temp\compsnotline.txt"
	}
}

Open in new window


That should do it.
kevinhsiehNetwork Engineer

Commented:
Since you obviously have an internal connection to your devices, you can still use WSUS for updates. WSUS doesn't need connection to the Internet.
http://www.wsusoffline.net/

Author

Commented:
I fought for it but its not allowed. now the only option I have is to run it form a file server

Author

Commented:
Alex

the script does nothing

$Computers = Get-Content "c:\temp\listofcomputers.txt"
ForEach ($Computer in $Computers) {
      If (Test-Connection -ComputerName $Computer -Quiet) {
            & PSEXEC.exe "\\$($Computer)" /accepteula -u "abc\administrator" -p "Password1" -i 2 -d \\\\192.168.1.100\IE32\IE11-Setup-Full.msi
      } Else {
            "$($Computer) is not online" | Out-File -Append "C:\temp\compsnotline.txt"
      }
}
Technical Specialist
Awarded 2017
Distinguished Expert 2018
Commented:
No need to use Powershell to loop command for multiple computers, it support lists.

Secondly, psexec can copy the file using -c so no need to use UNC paths either.

Lastly, psexec 2.1 encrypts credentials over the wire so -p -u does not transmit clear-text

Author

Commented:
could you kindly give me the complete command

a file server on which I will either have a .msi for a .vbs for example \\fileserver1\share\ie11.msi or vbs

on the admin workstation I will install pstools and create a text file on c:\temp\computerlist.txt

firstly I want to run run this using an admin account.

I want to copy the package locally on the client and then run the .msi or vbs

appreciate a quick response as I have to test it in the lab before I implement this

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial