Checks that an object isn't empty.
Assert-NotEmpty [[-InputObject] <Object>] [[-Message] <String>] [<CommonParameters>]
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.
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 |
Assert-NotEmpty 'That was close!'
Demonstrates how to check if a string is empty, which in this case it isn't.
Assert-NotEmpty @()
Demonstrates an easy way to fail a test: assert that an empty array is not empty.
Assert-NotEmpty @{ Foo = 'Bar' } 'Settigs not loaded.'
Demonstrates how to add a message to the failure message.