When a terminating error is thrown from the script, PowerShell.EndInvoke(IAsyncResult) will throw the exception and there is no way to get the partial results back (output from before the terminating error).
It would be good to make it able to return the partial results when a terminating error is thrown.
Steps to reproduce
$ps = [powershell]::Create()
$ps.AddScript("'Hello World'; gcm blah -ea stop; 'yeah'") > $null
$a = $ps.BeginInvoke()
$b = $Ps.EndInvoke($a)
Expected behavior
Throw the exception, but at the same time allow the users to get the partial results back.
Actual behavior
Exception is thrown, $b is null, and the partial output is lost.
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0
PSEdition Core
GitCommitId 6.1.0
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
When a terminating error is thrown from the script,
PowerShell.EndInvoke(IAsyncResult)will throw the exception and there is no way to get the partial results back (output from before the terminating error).It would be good to make it able to return the partial results when a terminating error is thrown.
Steps to reproduce
Expected behavior
Throw the exception, but at the same time allow the users to get the partial results back.
Actual behavior
Exception is thrown,
$bis null, and the partial output is lost.Environment data