Assert-LastProcessSucceeded

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

Name Type Description Required? Pipeline Input Default Value
Message String

The message to show if the assertion fails.

false false

EXAMPLE 1

Assert-LastProcessSucceeded

Demonstrates how to assert that the last process succeeded.

EXAMPLE 2

Assert-LastProcessSucceeded 'cmd.exe'

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