Compare 2 files and get line number $abc = gc .\z.txt | %{$i = 1} { new-object psobject -prop @{LineNum=$i;Text=$_}; $i++ } $cde = gc .\x.txt | %{$i = 1} { new-object psobject -prop @{LineNum=$i;Text=$_}; $i++ } Compare-Object $abc $cde -Property Text -PassThru -IncludeEqual Read more →