Same command works with enter-pssession but not invoke-command

I'm trying to run an executable remotely with powershell. Right now I'm trying to install Office 2013 SP1, but in the past I've had the same issue with other executables.

The command I'm running is as follows:

Invoke-Command -computername computer01 -scriptBlock {C:\windows\Temp\proplussp2013-kb2817430-fullfile-x86-en-us.exe /quiet}

It finishes almost immediately, returning no result, having not installed anything.

However, if I do the following, it works just fine:

Enter-PSSession computer01
C:\windows\Temp\proplussp2013-kb2817430-fullfile-x86-en-us.exe /quiet
Any idea what my problem with Invoke-Command is?

August 8th, 2014 2:37pm

Invoke-Command -Computername computer01 -ScriptBlock {
    Start-process "C:\windows\Temp\proplussp2013-kb2817430-fullfile-x86-en-us.exe /quiet" }
Start-Process will
Free Windows Admin Tool Kit Click here and download it now
August 8th, 2014 3:02pm

Unfortunately that didn't work. I get the following error: "This command cannot be run due to the error: The system cannot find the file specified." This even though the file definitely exists.

I also tried removing the quotes, which results in the prompt hanging indefinitely.

August 8th, 2014 6:09pm

Are you absolutely sure that the file exists on the remote machine?

What's the output of this:


Test-Path \\computer01\c$\Temp\proplussp2013-kb2817430-fullfile-x86-en-us.exe

Free Windows Admin Tool Kit Click here and download it now
August 8th, 2014 6:23pm

As Mike said you should have your exe source file in the machine you trigger it. if not copy and paste it in the remote machine.

August 8th, 2014 7:31pm

Yes, I'm absolutely certain. Test-path returns true. And if I copy and paste the exact same command within the brackets but run it within a PSSession, it works fine.
Free Windows Admin Tool Kit Click here and download it now
August 8th, 2014 8:01pm

Any chance there's something about this executable that prevents it from running in a non-interactive environment?  

Does it work if you use do the Enter-PSSession, and then try to launch it with Start-Process?

August 8th, 2014 8:13pm

Hi Eric,

Any updates on this issue?

If there is anything else regarding this issue, please feel free to post back.

If you have any feedback on our support, please click here.

Best Regards,

Anna Wang

Free Windows Admin Tool Kit Click here and download it now
August 19th, 2014 4:14pm

I did an Enter-PSSession, then ran the command using start-process. It hangs indefinitely. I did have to change the command a little, because I couldn't just put the whole command in quotes - that gave me an error saying the file wasn't found. I separated it into -filepath and -argumentlist params. Below is what I ran:

Enter-PsSession -computername computer01
start-process -filepath "C:\windows\Temp\proplussp2013-kb2817430-fullfile-x86-en-us.exe" -argumentlist "/quiet"

This resulted in the session hanging indefinitely. So here is where I'm at:

  1. Enter-PsSession then running the command works
  2. Invoke-command with the command immediately finishes, with no output and the program doesn't actually install
  3. Enter-PsSession then running start-process hangs indefinitely
  4. Invoke-Command plus start-process hangs indefinitely

I was curious to see if this held true with other programs, so I tried installing a program from HP with a silent switch and got identical behavior throughout all four scenarios listed above. 

Turning off on-access A/V protection made no difference.

Finally, regarding mjolinor's question about the program running in non-interactive environments: to the best of my knowledge the program can - but I'm not positive. I would assume, however, that invoke-command would build the same sort of environment as Enter-PsSession does, and it works there.

August 20th, 2014 6:01pm

I understand this is very old thread but is still coming up in google as a good result. In most cases if a command works in enter-pssession but goes blank on invoke-command its normally the process gets killed. When using invoke-command when the async call fires for the installer it doesn't have enough time before the invoke-command closes the connection which will end that process before it can spawn its async installer module to run in the background. When your using enter-pssession it allows process to fire since connection to the server stays open. I hope this helps and or clears up why the behavior seems different. 

Adding -wait should work for alot of async slient / quiet installers

invoke-comannd -computername $Server -scriptblock {start-process  "C:\path\Setup.exe" -ArgumentList "/S" -Wait}

Or less perferred method sleep

invoke-comannd -computername $Server -scriptblock {start-process  "C:\path\Setup.exe" -ArgumentList "/S"; sleep 2}

Free Windows Admin Tool Kit Click here and download it now
July 20th, 2015 11:46am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics