The string element in array

I have the array and the string:
$Array = “1”, “2”, “3”
$String1 = “456”
$String2 = “451”

And I need to check, is string contain one of array elements. Like:
Is String1 contains Array? -False
Is String2 contains Array? -True
How can I do that?

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in 1 <---- Click :point_up_2:t4: :wink:

( !! Sometimes the preformatted text button hides behind the settings gear symbol. :wink: )

You could use Select-String with the string as -InputObject and $Array as the -Pattern.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.