Hello @Rick S
After reviewing the Microsoft documentation more closely, I need to correct and narrow my original conclusion.
My October 7 answer overstated the documented guarantees. I could not find an official Microsoft contract establishing that every internal error-reporting or invocation-finalization failure must either set HadErrors = true and retain an error record, or cause a terminating exception to escape PowerShell.Invoke().
The relevant API is specifically the non-generic synchronous System.Management.Automation.PowerShell.Invoke() overload, used with the fresh PowerShell instance and owned runspace described in the question. Documentation for Pipeline.Invoke() and RunspaceInvoke.Invoke() does not, by itself, establish the required guarantee for this exact call.
Microsoft documents the general behavior of Invoke(), HadErrors, and the error streams. However, I could not establish a documented guarantee covering every internal failure path, the ordering of error reporting and invocation completion, or consistent behavior across all Windows PowerShell 5.1 servicing builds.
Conclusion: The proposed reporting/finalization guarantee remains unresolved based on the public documentation reviewed. Establishing it would require implementation-specific evidence or confirmation from Microsoft for the exact Windows PowerShell 5.1 build and host conditions involved.
This does not establish that a silent failure occurred. The observed result alone is not proof of such a failure, nor does the absence of a documented guarantee prove that one occurred.
References:
Microsoft: PowerShell class and HadErrors
Microsoft: Pipeline.Invoke method
Microsoft: RunspaceInvoke.Invoke method
The latter two references provide related context but do not independently establish the guarantee for the specific PowerShell.Invoke() overload in question.
Thank you for the clarification. The guarantee remains unresolved pending further evidence or Microsoft confirmation.
If this information was helpful, please click Accept Answer.
Thank you for choosing Microsoft Q&A.