Assert-ContainsLike

Asserts that a collections contains an item, using wildcards to check.

Syntax

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

Description

Compares each item in a collection for a value using PowerShell's -like operator.

Parameters

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

EXAMPLE 1

Assert-ContainsLike @( 'foo', 'bar', 'baz' ) 'b*'

Demonstrates how to check if a collection contains an item, using wildcards when doing the comparison.

EXAMPLE 2

Assert-ContainsLike @( 'foo', 'bar' ) '*z' 'No Z!'

Demonstrates how to supply your own message when the assertion fails.