As a part of a script for modifying a CSV, I am checking against a column subCatDesc to determine a Team based on predetermined values stored in an array.
$grocerySubTeams = "Grocery","Frozen","Bulk","Dairy"
function identifyTeam() {
foreach ($row in $csv) {
if ($row.subCatDesc -contains $grocerySubTeams) {
$row.team = "Grocery"
}
}
}
When running the script with this the Team column remains empty. However if I explicitly spell out what I want like below, it works.
function identifyTeam() {
foreach ($row in $csv) {
if (($row.subCatDesc -like "Grocery") -or ($row.subCatDesc -like "Frozen") -or ($row.subCatDesc -like "Bulk") -or ($row.subCatDesc -like "Dairy")) {
$row.team = "Grocery"
}
}
}
I've tried different comparison operators against the array instead of -contains, but none work.
Get-Help about_Comparison_Operators -ShowWindow.-inis for one-to-many, and-containsis its inverse