1

I'm currently working on a project that compares the e-mail addresses in two different csv files using the compare-object function in PowerShell. This works fine to deliver an output that tells me if the email address was found in one or both of the csv files. However, is there a way for me to also grab the information from the other columns in one of the csv files (i.e. name, phone number, etc.)? One csv file has only email addresses, the other has a few different columns. I want to output the comparisons along with select other column information from the other csv file and output that all into one single csv.

$file1 = import-csv -Path "c:\users\$env:USERNAME\Desktop\file1.csv"
$file2 = import-csv -Path "c:\users\$env:USERNAME\Desktop\file2.users.csv"
Compare-Object $file1 $file2 -property EmailAddress -IncludeEqual | Export-Csv c:\users\$env:USERNAME\Desktop\file3.csv

The above code is what I've been working with so far. It does everything I want it to, I just can't figure out how to include the output of other columns into the resulting csv file. If I have to take a totally new route, I'm open to suggestions.

A. Johnson
  • 11
  • 2

0 Answers0