View Single Post
Old 07-06-2007   #2 (permalink)
Marco Shaw


 
 

Re: Comparing files with compare-object

More info...

If I try to do an exact match for the -referenceobject and
-differenceobject, I can get a match.

This works:

85# compare-object -referenceobject $(get-content
1.txt|%{$_.substring(13,56)}|%{$_.trimend()}|%{if($_ -mat
ch "some_user_removed"){$_}}) -differenceobject $(import-csv
2.csv|%{$_.'SN,CN'}|%{$_.replace(' (+)','')}|%
{if($_ -match "some_user_removed"){$_}}) -includeequal -excludedifferent

InputObject SideIndicator
----------- -------------
some_user_removed ==

But again, this doesn't:

86# compare-object -referenceobject $(get-content
1.txt|%{$_.substring(13,56)}|%{$_.trimend()}) -difference
object $(import-csv 2.csv|%{$_.'SN,CN'}|%{$_.replace(' (+)','')})
-includeequal -excludedifferent
87#

My understanding is compare-object is not supposed to be a match line X
in file A with match line X in file B. In other words, line X in file A
can still be found to be a match with line Y in file B as long as the
content/string is the same.
My System SpecsSystem Spec