< Back

Assert-DoesNotContain

Sun Jan 12, 2020 5:35 pm

NAME Assert-DoesNotContain



SYNOPSIS

Asserts that a collection doesn't contain an object/item.





SYNTAX

Assert-DoesNotContain [[-Haystack] <Object>] [[-Needle] <Object>] [[-Message] <String>] [<CommonParameters>]





DESCRIPTION

Use's PowerShell's `-contains` operator to check that a collection is missing an object/item.





PARAMETERS

-Haystack <Object>

The collection to check.



Required? false

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Needle <Object>

The object the collection shouldn't have.



Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Message <String>

A message to show when the assertion fails.



Required? false

Position? 3

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-DoesNotContains @( 1, 2, 3 ) 4



Demonstrates how to assert a collection doesn't contain an item.









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



PS C:\\>Assert-DoesNotContain @( 1, 2, 3 ) 3 'Three is the loneliest number.'



Demonstrates how to show your own message if the assertion fails.











RELATED LINKS