Checks that an object is empty.
Assert-Empty [[-InputObject] <Object>] [[-Message] <String>] [<CommonParameters>]
This checks that an object's Length
or Count
property is equal to 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 object to check. |
false | false | |
Message | String | A descriptive message to show if the object isn't empty. |
false | false |
Assert-Empty ''
Demonstrates how to check if a string is empty, which in this case it is.
Assert-Empty @()
Demonstrates that collections can be checked as well as strings.
Assert-Empty @{ Foo = 'Bar' } 'Settings not initialized.'
Demonstrates how to show your own message when the assertion fails.