Asserts that a collections contains an item, using wildcards to check.
Assert-ContainsLike [[-Haystack] <Object>] [[-Needle] <Object>] [[-Message] <String>] [<CommonParameters>]
Compares each item in a collection for a value using PowerShell's -like
operator.
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
Haystack | Object | The collection to check. |
false | false | |
Needle | Object | The object to check the collection for. Wildcards supported. |
false | false | |
Message | String | A message to show when the assertion fails. |
false | false |
Assert-ContainsLike @( 'foo', 'bar', 'baz' ) 'b*'
Demonstrates how to check if a collection contains an item, using wildcards when doing the comparison.
Assert-ContainsLike @( 'foo', 'bar' ) '*z' 'No Z!'
Demonstrates how to supply your own message when the assertion fails.