Hello @Rick S
Welcome to Microsoft Q&A!
Thank you for your patience, and taking the time to elaborate on your concerns.
You’ve pinpointed the subtle distinction between cmdlet‑level failures and engine‑level reporting/finishing failures in Windows PowerShell 5.1, and the guarantees around synchronous Invoke().
Supported Contract in PowerShell 5.1 Hosting.
1. Cmdlet Processing Failures
Errors thrown inside cmdlet ProcessRecord, BeginProcessing, or EndProcessing are captured into the error pipeline.
HadErrors is set to true before the pipeline is marked Completed.
The error record is retained in Streams.Error and surfaced to the caller.
Terminating errors bubble up as exceptions, preventing a usable result.
2. Engine Reporting/Finishing Failures
If the engine itself fails while constructing or delivering an error record, the synchronous Invoke() does not return a “clean” result.
Instead, the hosting contract guarantees a terminating exception is thrown to the caller.
This prevents the state you described (Completed + HadErrors false + empty error collection + valid output) from occurring alongside an unreported adverse outcome.
3. Ordering and Relationships
HadErrors is set before the pipeline is marked Completed.
Error records are finalized before output is returned.
If error reporting cannot be finalized, Invoke() throws, and no usable result is returned.
4. Supported Outcomes
Cmdlet error → error record in stream, HadErrors true, Completed state.
Engine reporting failure → terminating exception, no usable result.
Host termination → only if the host process itself crashes.
Silent failure (clean result with hidden adverse outcome) → not supported.
5. Scope
Applies to Windows PowerShell 5.1 generally across servicing builds on .NET Framework.
No documented exclusions where reporting failures are ignored.
Only unmanaged host corruption (e.g., memory faults) falls outside the supported contract.
In Summary: In Windows PowerShell 5.1, synchronous Invoke() guarantees that you will never see a “clean” invocation result if the engine fails during error reporting or completion. Either you get an error record with HadErrors = true, or you get a terminating exception. Silent adverse outcomes with no errors are not supported.
This means your caller screen (Completed state, HadErrors false, empty error collection, one valid receipt object) cannot be satisfied if a reporting failure occurs, the runtime enforces that guarantee.
I hope this helps to better understand the diagnostic options available and the risks involved.
If this information was helpful, please click Accept Answer.
Thank you for choosing Microsoft Q&A.