When you post code please use the "Code Sample" editor. The icon is the 5th from the left on the Format Bar and has the graphic "101 010". The normal editor makes a mess of code, as you can see by looking at your post!
In any case, is this more-or-less what you want to do?
$f1 = [PSCustomObject]@{Hash = "abc"},[PSCustomObject]@{Hash = "def"},[PSCustomObject]@{Hash = "ghi"},[PSCustomObject]@{Hash = "jkl"}
$f2 = [PSCustomObject]@{Hash = "abc"},[PSCustomObject]@{Hash = "xyz"},[PSCustomObject]@{Hash = "ghi"},[PSCustomObject]@{Hash = "jkl"}
$f1p = $f1.psobject[0].Properties.name | Sort-Object
$f2p = $f2.psobject[0].Properties.name | Sort-Object
$x = Compare-Object $f1p $f2p
if ($x.Length -ne 0){
Throw "Properties are not the same!`r`n$f1p`r`n`r`n$f2p"
}
Compare-Object $f1 $f2 -IncludeEqual -Property Hash |
Where-Object {$_.SideIndicator -eq "=="} | # just find what's equal
Select-Object Hash |
Export-Csv c:\junk\equalvalues.csv -NoTypeInformation
Compare-Object $f1 $f2 -Property Hash |
Where-Object {$_.SideIndicator -eq "=>"} |
Select-Object Hash |
Export-CSV c:\junk\NotInReferenceSet.csv -NoTypeInformation
Compare-Object $f1 $f2 -Property Hash |
Where-Object {$_.SideIndicator -eq "<="} |
Select-Object Hash |
Export-CSV c:\junk\NotInDifferenceSet.csv -NoTypeInformation