Search code examples
windowspowershellexeinvoke-command

Powershell: Remote exe Installation


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!


Solution

  • 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.