< Back

Assert-LastProcessFailed

Sun Jan 12, 2020 5:43 pm

NAME Assert-LastProcessFailed



SYNOPSIS

Asserts that the last process failed by checking PowerShell's `$LastExitCode` automatic variable.





SYNTAX

Assert-LastProcessFailed [[-Message] <String>] [<CommonParameters>]





DESCRIPTION

A process fails if `$LastExitCode` is non-zero.





PARAMETERS

-Message <String>

The message to show if the assertion fails.



Required? false

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Assert-LastProcessFailed



Demonstrates how to assert that the last process failed.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Assert-LastProcessFailed 'cmd.exe'



Demonstrates how to show a custom message when the assertion fails.











RELATED LINKS