Check if an array contains a certain string

taijidude - Nov 7 '20 - - Dev Community

Last week I was searching through a huge array of strings by hand/eye. I was looking for certain active directory groups. I quickly realized how stupid this was and researched ("googled" ;-)) how to check if a powershell array contains a string. "-match" comes to the rescue here.

Example:

    $data = @('Zero','One','Two','Three')
    $data -match 'Two'
Enter fullscreen mode Exit fullscreen mode

Output:
Alt Text

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player