Compare group membership from two AD accounts with Powershell

Hi EE

Anyone have a script that will compare the group membership from two accounts in active directory ?

Compare account A from account B and tell me the groups missing from account A
LVL 2
MilesLoganAsked:
Who is Participating?
 
SeanConnect With a Mentor System EngineerCommented:
Sorry - will still be the same idea only use Get-ADPrincipalGroupMembership in place of Get-ADGroupMember

so -

$a = Get-ADPrincipalGroupMembership -Identity Username
$b = Get-ADPrincipalGroupMembership -Identity Username
compare $a $b
0
 
SeanSystem EngineerCommented:
$a= Get-ADGroupMember GroupA
$a | Select name

$b = Get-ADGroupMember GroupB
$b| Select name

compare-object $a $b

You could easily turn this into a script.
0
 
MilesLoganAuthor Commented:
Hi Zindel1 .. I am needing to compare two accounts .. not groups ..
0
 
MilesLoganAuthor Commented:
Zindel1 thanks !!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.