Skip to content

PowerShell.EndInvoke(IAsyncResult) doesn't provide a way for users to get the partial results when a terminating error is thrown #8005

@daxian-dbw

Description

@daxian-dbw

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions