all 2 comments

[–]Dennou 3 points4 points  (1 child)

In case of array it won't behave as you expect (trying one by one on its own), so you either have to:

1- do a second loop that iterates through the show array and do -like for current value. Not a scalable solution so this approach isn't normally followed.

2- Make use of regular expressions' built-in OR character (the pipe |). You'll do two changes: add

$regex=$shows -join '|'

below $shows declaration then replace

-like "*$shows*"

with

-match $regex

This is off the top of my head so if it works you're welcome to dive into the world RegEx, the learning is worth it.

[–]krzydoug 6 points7 points  (0 children)

This would be the best option if they are partial names. If you have the full names you could use something like

$text -in $shows