If I remotely invoke the following Powershell script:
"Starting..."
$r=1/0
"Finish"
With something like this:
$s = New-PSSession -ComputerName mycomputer
$result=Invoke-Command -Session $s -Script { d:\go.ps1 }
$result
I only get the error message for the division by zero. The "Starting..." message is lost.
How can I retrieve all of the output from the remote command in the event of an error?