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.