by Andre at 2013-03-11 03:43:00
I’m stil learning powershell but i need a quick solution for a problem.by DonJ at 2013-03-11 06:17:47
The problem is: How can i execute the e:\update.exe file with the parameter
/verysilent on a remote computer.
We have a program called Wisa, installed upon nearly 400 pc’s.
Nearly every 2 month there’s an update. Until now we do the update via
rdp, download the update from a local server and execute it with a
parameter /verysilent. As you can imagine this is a lot of work. We’re
trying to do a little more automatic. So we have an extra drive on
our pc’s (all w7), the e:drive and we can already copy the update via
copy-item to all the pc’s.
The command we use is:
copy-item \dc01\e$\shares\wisa\updates\CSWisAdmin_clupd_220.127.116.11.exe \site-ne-sec-01\e$
On all pc’s now we also have remote powershell enabled.
I can enter-pssession site-ne-sec-01 to connect, no problem.
Than i execute the command e:\cswisadmin_clupd_18.104.22.168.exe /verysilent, no problem
and leave the remote pc with exit-pssession, no problem.
This is already a major time improvement for us.
But i want to trigger the update from my management pc.
I tried the invoke-command but i’m no able to find the correct syntax.
I also tried the invoke-command with the filepath parameter.
Loacal scriptname is update.ps1
In this script the only line is: e:\cswisadmin_clupd_22.214.171.124.exe /verysilent
then the invoke command:
Invoke-command -computername site-ne-sec-01 -filepath c]
But it doesn’t work.
Any help is appreciated.
Invoke command probably isn’t giving the command time to complete. Try starting a session and invoking the command against the session instead of a computer name. And obviously confirm that the executable is already on the remote machine.by Andre at 2013-03-11 07:45:48
Thx for the quick response.by DonJ at 2013-03-11 08:19:18
I’m sure the executable is on the remote machine because manually i can start it via enter-pssession and the computername.
I’m new to powershell and have no idee what you mean by ‘invoking the command against a session’.
Can you provide me some programming that i can work with to find a solution.
$s = new-PSsession -computer WHATEVER
Invoke-command -file whatever -session $s