Compare Difference between memberof details of multiple users

$Adusers = Import-csv “path\users_compare.csv”
add-content “path2\Script\compare.csv” “name,Pid,group”
Foreach($Aduser in $Adusers)
{
$user1 = $Aduser.name
$member1 = (Get-ADUser $user1 –Properties MemberOf).MemberOf | % {$.split(",")[0].replace(“CN=”,"")}
$user2 = $Aduser.Pid
$member2 = (Get-ADUser $user2 –Properties MemberOf).MemberOf | % {$
.split(",")[0].replace(“CN=”,"")}

$adgroups = Compare-Object -ReferenceObject ($member1) -DifferenceObject ($member2) -IncludeEqual | ?{$_.sideindicator -eq ‘<=’} | select inputobject
Foreach($Adgroup in $Adgroups)
{
$data = $user1 + “,” + $user2 + “,” + $adgroup.inputobject
add-content “path2\compare.csv” $data
}
}

If you need help you will have to ask a question