< Back
Assert-Empty
Post
NAME Assert-Empty
SYNOPSIS
Checks that an object is empty.
SYNTAX
Assert-Empty [[-InputObject] <Object>] [[-Message] <String>] [<CommonParameters>]
DESCRIPTION
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.
PARAMETERS
-InputObject <Object>
The object 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-Empty ''
Demonstrates how to check if a string is empty, which in this case it is.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Assert-Empty @()
Demonstrates that collections can be checked as well as strings.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Assert-Empty @{ Foo = 'Bar' } 'Settings not initialized.'
Demonstrates how to show your own message when the assertion fails.
RELATED LINKS
SYNOPSIS
Checks that an object is empty.
SYNTAX
Assert-Empty [[-InputObject] <Object>] [[-Message] <String>] [<CommonParameters>]
DESCRIPTION
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.
PARAMETERS
-InputObject <Object>
The object 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-Empty ''
Demonstrates how to check if a string is empty, which in this case it is.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Assert-Empty @()
Demonstrates that collections can be checked as well as strings.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Assert-Empty @{ Foo = 'Bar' } 'Settings not initialized.'
Demonstrates how to show your own message when the assertion fails.
RELATED LINKS