You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to retrieve the exit code for a PowerShell session (in which the exit command is used), must one instantiate a PSHost instance and provide to the runspace pool?
It seems like PowerShell.poll_invoke and/or PowerShell.end_invoke should also return this exit code, or at least it should be accessible in an easy way.
The text was updated successfully, but these errors were encountered:
It's just not possible to get the exit code without first providing a host. The PSRP messages exchanged do not return this value in any shape or form except through the SetShouldExit host call so in order to retrieve it you need to provide a host yourself and implement this method. Technically WSMan itself has an ExitCode field in the ReceiveResponse of the final pipeline message but it does not reflect what was used with exit in the running pipeline (it is always 0). Other transports have no similar transport specific field for this so even if the WSMan one worked you couldn't implement it in a transport agnostic way.
In order to retrieve the exit code for a PowerShell session (in which the
exit
command is used), must one instantiate aPSHost
instance and provide to the runspace pool?It seems like
PowerShell.poll_invoke
and/orPowerShell.end_invoke
should also return this exit code, or at least it should be accessible in an easy way.The text was updated successfully, but these errors were encountered: