PowerShell – Comparing Two Arrays

0
30

Find difference in two array

$Array1=@("John","Mark")
$Array2=@("Mike","Paul","Bill","John","Mark")
$ArrayDiff=$Array2 | Where {$Array1 -NotContains $_}

Find common in two array

$Array1=@("John","Mark")
$Array2=@("Mike","Paul","Bill","John","Mark")
$ArrayDiff=$Array2 | Where {$Array1 -Contains $_}