Powershell-CompareCsv-Export-Values-From-Each I posted that question and its pretty much identical, except that my right CSV has multiple Rows with the same First, Last, and DOB, but different file names and the my Left File only has the First, Last, DOB one time.
I think the answer will be different enough that I decided to post a second question.
i Have 2 CSV's
left.csv
Ref_ID,First_Name,Last_Name,DOB
321364060,User1,Micah,11/01/1969
946497594,User2,Acker,05/28/1960
887327716,User3,Aco,06/26/1950
588496260,User4,John,05/23/1960
565465465,User5,Jack,07/08/2020
right.csv
First_Name,Last_Name,DOB,City,Document_Type,Filename
User1,Micah,11/01/1969,Parker,Transcript,T4IJZSYO.pdf
User1,Micah,11/01/1969,Parker,Letter,BADBADC.pdf
User1,Micah,11/01/1969,Parker,Resume,AJMLMOC.pdf
User2,Acker,05/28/1960,,Transcript,R4IKTRYN.pdf
User3,Aco,06/26/1950,,Transcript,R4IKTHMK.pdf
User4,John,05/23/1960,,Letter,R4IKTHSL.pdf
I need to match them on First_Name,Last_Name,DOB then return Ref_ID from the left.csv and First, Last, DOB, Document_Type,Filename from the right.csv for each row.
So the end Result would look like this:
Combined.csv
Ref_ID,First_Name,Last_Name,DOB,Document_Type,Filename
321364060,User1,Micah,11/01/1969,Transcript,T4IJZSYO.pdf
321364060,User1,Micah,11/01/1969,Letter,BADBADC.pdf
321364060,User1,Micah,11/01/1969,Resume,AJMLMOC.pdf
946497594,User2,Acker,05/28/1960,Transcript,R4IKTRYN.pdf
887327716,User3,Aco,06/26/1950,Transcript,R4IKTHMK.pdf
588496260,User4,John,05/23/1960,Letter,R4IKTHSL.pdf
Using the answer from the other post, only returns the first match. I tried changing -eq to -in, which gives me all the matches, but that returns it like this:
Ref_ID,First_Name,Last_Name,DOB,Document_Type,Filename
321364060,{User1,User1,User1},{Micah,Micah,Micah},{11/01/1969,11/01/1969,11/01/1969},{Transcript,Letter,Resume},{T4IJZSYO.pdf,BADBADC.pdf,AJMLMOC.pdf}
The query below works to get me each individual results, but i don't know how to add the REF_ID i need from the left.csv
$right.Where( {$_.DOB -in $left.DOB -and $_.First_Name -in $left.First_Name -and $_.Last_Name -in $left.Last_Name}) |
export-csv C:\Combined.csv -notypeinformation
Results: It allows me to do -in, It excluded User5, since it doesnt match, but i need the REF_Id returned
First_Name,Last_Name,DOB,City,Document_Type,Filename
User1,Micah,11/01/1969,Parker,Transcript,T4IJZSYO.pdf
User1,Micah,11/01/1969,Parker,Letter,BADBADC.pdf
User1,Micah,11/01/1969,Parker,Resume,AJMLMOC.pdf
User2,Acker,05/28/1960,,Transcript,R4IKTRYN.pdf
User3,Aco,06/26/1950,,Transcript,R4IKTHMK.pdf
User4,John,05/23/1960,,Letter,R4IKTHSL.pdf
I feel like i am just missing an operator that would put the results the way i need/want but I tried adding -join or -split into pscustomobject but with no luck, or a count+1 so it loops through those, or a nested foreach-object, really at a loss.