I have a csv file that contains a host of columns but only 2 are relevant: "Emails" and "Followup". The Emails column contains a list of email addresses, and Followup contains either Y's or N's; I have 1 Y and 7 N's. I'm working with a header row and then 8 rows of data.
So far, I have this script:
$File = Import-Csv -Path "C:\file.csv"
$Addresses = @($File.email)
$Followup = @($File.followup)
$To = @($Addresses | Where-Object {$Followup -eq "Y"})
$Addresses
$Followup
$To
I'm trying to create another array ($To) that contains only those email addresses that are paired with a "Y" in the Followup column.
For my output, I'm getting 8 email addresses (good), 7 N's and 1 Y (good), and 8 email addresses again (bad, desired outcome is 1).
What am I fouling up here?