Assert-NotEmpty

Checks that an object isn't empty.

Syntax

Assert-NotEmpty [[-InputObject] <Object>] [[-Message] <String>] [<CommonParameters>]

Description

This checks that an object's Length or Count property is greater than 0. That means this function should be used with strings or collections, or similar objects.

Parameters

Name Type Description Required? Pipeline Input Default Value
InputObject Object

The objec to check.

false false
Message String

A descriptive message to show if the object isn't empty.

false false

EXAMPLE 1

Assert-NotEmpty 'That was close!'

Demonstrates how to check if a string is empty, which in this case it isn't.

EXAMPLE 2

Assert-NotEmpty @()

Demonstrates an easy way to fail a test: assert that an empty array is not empty.

EXAMPLE 3

Assert-NotEmpty @{ Foo = 'Bar' } 'Settigs not loaded.'

Demonstrates how to add a message to the failure message.