< Back

Assert-NotEmpty

Sun Jan 12, 2020 5:48 pm

NAME Assert-NotEmpty



SYNOPSIS

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

-InputObject <Object>

The objec to check.



Required? false

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Message <String>

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



Required? false

Position? 2

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-NotEmpty 'That was close!'



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









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



PS C:\\>Assert-NotEmpty @()



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









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Assert-NotEmpty @{ Foo = 'Bar' } 'Settigs not loaded.'



Demonstrates how to add a message to the failure message.











RELATED LINKS