Compare Two CSVs



Compare two CSV files and find unique values.


$header = "fname","lname"

$import1 = Import-Csv .\output1.csv -header $header | sort username -Descending
$import2 = Import-Csv .\output2.csv -header $header | sort username -Descending

$a = New-Object System.Collections.ArrayList
foreach ($user in $import1)
{
foreach ($user in $import2)
{
if($PSuser.fname -eq $ADuser.fname -and $PSuser.lname -eq $ADuser.lname)
{

$user = $PSuser.fname+','+$PSuser.lname
$a += ($user)
}
}
}
$a | out-file export.csv
$newexport = Import-Csv .\export.csv -header $header | sort fname,lname -Unique
$newexport | export-csv nodupeexport.csv

#$ArrayList
#Compare-Object $PSimport $ADimport -property MPFriendlyName -IncludeEqual