This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Will list the content present in Both the files | |
$file1 = import-csv -Path "C:\ps\output\obj1.csv" | |
$file2 = import-csv -Path "C:\ps\output\obj2.csv" | |
[linq.enumerable]::intersect( [object[]]($file1.name), [object[]]($file2.name) ) | Export-Csv -NoTypeInformation -Path "C:\ps\result\result.csv" | |
## will list the content present either in one of the files but not in both | |
$file1 = import-csv -Path "C:\ps\output\obj1.csv" | |
$file2 = import-csv -Path "C:\ps\output\obj2.csv" | |
$res = [Collections.Generic.HashSet[String]]( [string[]]($file1.name) ) | |
$res.SymmetricExceptWith( [string[]]($file2.name) ) | |
$res | Export-Csv -NoTypeInformation -Path "C:\ps\result\result.csv" | |
## For union operation, you can try like this | |
[system.linq.enumerable]::union([object[]](1,2,3),[object[]](2,3,4)) |