How it works...
The match and like comparison operators can take input as single elements or as arrays. When the operators are used on arrays, the comparison operation runs on each of the elements of the array. Think of this as being equivalent to the Where-Object-based filtration. In other words, $NewNames -match 'son' is very similar to using $NewNames | Where-Object { $PsItem -match 'son' }.
That brings us to performing some more complex filtration; when such a need arises, use the Where-Object cmdlet instead of a plain match or like on the array. Performing Boolean AND or OR operations with plain matching and multiple conditions will only produce a Boolean output. For instance, if you are using the name list supplied with the chapter, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access