< Back

Assert-LastProcessSucceeded

Sun Jan 12, 2020 5:43 pm

NAME Assert-LastProcessSucceeded



SYNOPSIS

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





SYNTAX

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





DESCRIPTION

A process succeeds if `$LastExitCode` is 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-LastProcessSucceeded



Demonstrates how to assert that the last process succeeded.









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



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



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











RELATED LINKS