Assert-NoError

Tests that the $Error stack is empty.

Syntax

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

Description

I guess you could just do Assert-Equal 0 $Error.Count, but Assert-NoError is simpler.

Parameters

Name Type Description Required? Pipeline Input Default Value
Message String

The message to show when the assertion fails.

false false

EXAMPLE 1

Assert-NoError

Demonstrates how to assert that there are no errors in the $Error stack.

EXAMPLE 2

Assert-NoError -Message 'cmd.exe failed to install junction!'

Demonstrates how to show a descriptive message when there are errors in the $Error stack.