0

I am trying to compare to CSV files with the exact same headings (parent ID, Folder Name, Folder Code 1) However, it's not showing all the data. For example, I know one class is Called "7 Food and Hospitality 2 2021" but the output doesn't show this in the results.
enter image description here

However, when I just compare 1 column (folder Name) it states the difference correctly. However, I need the output of all columns as this is in the format for bulk uploading into another system. enter image description here

The part of the code I am having is as followed:

$term1 = Import-Csv -Path 'C:\temp\Term 1.csv' | Select-Object 'parent ID','Folder Name','Folder Code 1'
$term2 = Import-Csv -Path 'C:\temp\Term 2.csv' | Select-Object 'parent ID','Folder Name','Folder Code 1'

$newClassess = Compare-Object -IncludeEqual -ReferenceObject $term2 -DifferenceObject $term1 | Select-object -ExpandProperty InputObject

As you can see in the term 1 CSV (snippet) there is not 7 Food and Hospitality 2 but there is in CSV term 2 enter image description here

Fallen Soul
  • 27
  • 1
  • 7
  • I barely use `Compare-Object` but reading MS Docs for the cmdlet seems like you need to add the properties you want to compare so try adding `-Property 'parent ID','Folder Name','Folder Code 1'`. See example 5 on https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/compare-object?view=powershell-7.1 – Santiago Squarzon Apr 12 '21 at 00:51
  • 1
    Thank you, that seems to have done it. Much appreciated. – Fallen Soul Apr 12 '21 at 01:49

0 Answers0