Pipelines, errors, and native exit codes
Pipelines
- PowerShell cmdlet pipelines pass objects. Parameters can accept pipeline input by value or by property name; use
Get-HelpandGet-Memberto inspect the contract. - A native process's stdin/stdout is a separate boundary from the PowerShell object pipeline. PowerShell 7.4 added byte-preserving behavior for native stdout redirection to files and byte data piped to native stdin; verify exact behavior on older runtimes and when combining stderr with stdout.
Errors and exit codes
- Non-terminating errors do not enter
catchby default. Use-ErrorAction Stopwhen a cmdlet failure must be handled there. - Native process status is reported through
$LASTEXITCODE; capture or check it immediately after the relevant command and interpret it according to that program's contract. A nonzero code does not always mean failure, and stderr output alone does not establish failure. - A native nonzero exit does not normally enter
catch.$PSNativeCommandUseErrorActionPreferencebecame stable in PowerShell 7.4 and can change this behavior when enabled.