1

How do I capture the result and/or output of the executable run inside the Start-Process portion of this Invoke-Command?

Invoke-Command -ComputerName $SvrName -ScriptBlock {
    Param ($arg1, $arg2)
    $process = Start-Process -PassThru -FilePath $arg1 -ArgumentList $arg2;
    $process.WaitForExit();
} -ArgumentList $exePath, $command

I want the rest of the script to stop execution if the executable invoked by Start-Process returns an error.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Mathew
  • 4,297
  • 4
  • 29
  • 38
  • 3
    take a look at http://stackoverflow.com/questions/8761888/powershell-capturing-standard-out-and-error-with-start-process – guiwhatsthat Apr 19 '17 at 08:57

0 Answers0