I have two CSVs in powershell that I am trying to extract data from and put into a csv. For example: contacts.csv with First, Last, Email mailinglist.csv with First,Last,Email
MailingList email is blank, and I need to pull the email addresses from contacts.csv
Mailinglist has some, but not all, of the contacts as contacts.csv. I need to pull the email addresses from contacts.csv only for the rows that have a match in Mailinglist.csv
So far I have:
$contacts = Import-Csv .\contacts.csv
$mailing = Import-Csv .\mailing.csv
$compare = $mailing | select $_ | $_ -notcontains $contacts
$email = $contacts | Select $_ | Where { $_ -contains $compare }
$compare gives me the correct First and Last columns. Correct being that it only returns values matching $mailing, not anything else.
The $email variable comes back empty.
Help? I have a spreadsheet with 850 records I would really like to not have to do manually...