I'm trying to filter out some data in a csv flie I'm reading to generate another file but I can't seem to get my where to work.
In a nut shell, I want to select all users that are missing some pieces of data (an email address and a manger) but for some user types (students and residents) I want to filter them out (even though they are missing a manager, if they have an e-mail address I want it filtered out)
This is what I tried but it didn't work and they more I look at it the more I think I have the logic wrong but I'm just stumped. I've spent a few hours on it now.
Import-CSV -Path $inputFile | where { ($_.email -lt "*" -or $_.manager -lt "*" ) -and ($_.usertype -notlike "*student*" -or $_.usertype -notlike "*resident*") -and $_.email -gt "*" ) } | select $userAttributes | export-csv $outputPathI also tried doing like a sub-query importing the users I want filtered out into an array and then doing a -notcontains but that didn't work either.
$filterOut = Import-Csv -Path $inputFile | where { ($_.userType -like "*Student*" -or $_.userType -like "*Resident*") -and $_.email -gt "*" } | select person_id
Import-CSV -Path $inputFile | where { ($_.email -lt "*" -or $_.manager -lt "*" ) -and $filterOut -notcontains $_.person_id } | select $userAttributes | export-csv $outputPath
Any ideas? Thanks for the help.