< Back

Assert-NoError

Sun Jan 12, 2020 5:48 pm

NAME Assert-NoError



SYNOPSIS

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

-Message <String>

The message to show when 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-NoError



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









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



PS C:\\>Assert-NoError -Message 'cmd.exe failed to install junction!'



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











RELATED LINKS