0

I have two csv. first one is for PC info.(pcinfo.csv)

enter image description here

R1234 has two PCs

Second one is for User-mail info(mail.csv)

enter image description here

R9876 has no mail address

I want to make master CSV based on User ID like as below;

enter image description here

$doc1 = import-csv c:\pcinfo.csv

$doc2 = import-csv c:\mail.csv

$outfile = import-csv c:\mail.csv

Compare-Object $doc1 $doc2 -Property ID -passthru | Where-Object{$_.SideIndicator -eq "=>"} | Select PCname, ID, Mail | Export-csv "c:\complete.csv" -NoTypeInfo

And it did not work properly

yisjin86
  • 3
  • 1
  • and there are some the other columns in PCinfo.CSV – yisjin86 Oct 27 '22 at 17:54
  • 1
    How would you tell the difference between Apple and Dell? They share the same ID. – Metzli_Tonaltzintli Oct 27 '22 at 18:16
  • Using this [`Join-Object script`](https://www.powershellgallery.com/packages/Join)/[`Join-Object Module`](https://www.powershellgallery.com/packages/JoinModule) (see also: [In Powershell, what's the best way to join two tables into one?](https://stackoverflow.com/a/45483110/1701026)): `Import-Csv .\pcinfo.csv |Join (Import-Csv .\mail.csv) -on ID` – iRon Oct 27 '22 at 19:15
  • Thank you but It did not work properly... – yisjin86 Oct 29 '22 at 03:20

0 Answers0