Reputation: 119
I'm having problems with my script that is designed to install an executable remotely. All of the preliminary actions of my script work just fine. I grab the host names of about a dozen computers from a text file. I use PSExec to Enable-PSRemoting. Then the installer is copied down to a temp directory on the remote computer. Everything works great, except for the important part. I just can't get it to install.
I've tried the following:
Invoke-Command -ComputerName remoteComp -ScriptBlock {C:\temp\installer.exe} -ArgumentList /SILENT
Invoke-Command -ComputerName remoteComp {Start-Process C:\temp\installer.exe -ArgumentList /SILENT -Wait}
I've tried using New-PSSession like this:
$s = New-PSSession -ComputerName remoteComp
Invoke-Command -Session $s -ScriptBlock {C:\temp\installer.exe} -ArgumentList /SILENT
None send any sort of error, they just do nothing. Commands that have -Wait just hang forever. If I put a -Sleep, it just waits the requested seconds and then finishes, accomplishing nothing. I don't know if this matters, but when I run the executable on the local computer with the /SILENT switch, it doesn't request any prompts but it does open an explorer window.
I tried to use PSExec.exe, but I get a similar result. It just hangs forever without any error. Thanks in advance for any help!
Upvotes: 1
Views: 19765
Reputation: 119
After fighting with this thing a little more, I was able to successfully install the exe by creating a batch file and then using
Invoke-Command -ComputerName remoteComp -ScriptBlock {C:\temp\installer.bat}
All that's in the batch file is
installer.exe /SILENT
Another way that worked for me was mentioned by ssaviers, I could use schtasks.exe to schedule a one time task.
Upvotes: 3
Reputation: 144
try the argument list inside ... if the exe supports it.
ex:
Invoke-Command -ScriptBlock { c:\temp\yourexe.exe /verysilent /norestart /log="c:\install.log"}
Please try.
Upvotes: 2