Assert-Null

Asserts that an object/value is $null.

Syntax

Assert-Null [[-Value] <Object>] [[-Message] <String>] [<CommonParameters>]

Description

Value is literally compared with $null.

Parameters

Name Type Description Required? Pipeline Input Default Value
Value Object

The value to check.

false false
Message String

The message to show when Value if not null.

false false

EXAMPLE 1

Assert-Null $null

Demonstrates how to assert a value is equal to $null.

EXAMPLE 2

Assert-Null '' 'Uh-oh.  Empty string is null.'

Demonstrates how to assert a value is equal to $null and show a custom error message.