DEV Community

taijidude
taijidude

Posted on • Edited on

1

Check if an array contains a certain string

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

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more