Link to home
Start Free TrialLog in
Avatar of SingAbout Martin
SingAbout Martin

asked on

Powershell: Combining a where statement with contains

I have a Powershell script where I'm using the following:

$CompanyList = 'Contoso'
Where {$_.Company -eq $CompanyList}

Open in new window


The above snippet works, however when I add multiple values to $Company (like below) it doesn't work anymore.
$CompanyList = 'Contoso','Adatum','Test'

Open in new window


So I tried something like this:
Where {$_.Company.Contains($CompanyList)}

Open in new window

But this also doesn't work. Any ideas how to make the Where statement which is only True if the Company value matches one of the strings in the $CompanyList variable?
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SingAbout Martin
SingAbout Martin

ASKER

Excellent. Thank you.