You can use the -contains
operator:
Get-ColumnNames $table | Where-Object { value1,value2,... -contains $_ }
It’s backwards, though with the collection of values on the left side.
In PowerShell 3 you can also use the -in
operator:
Where-Object { $_ -in value1,value2,... }
or even
Where-Object -In value1,value2,...
Also, a quirk of how PowerShell works with comparison operators, you can apply them directly to a collection on the left side:
Where-Object { value1,value2,... -eq $_ }
The -eq
operator here will either yield the respective element if it is in the list, or $null
(which coerces to $false
).