Link to home
Start Free TrialLog in
Avatar of Erwin Pombett
Erwin PombettFlag for Switzerland

asked on

with powershell what is a good way to compare groups memberof difference between two accounts ?

Hello,

what's a good way for have the difference between two  accounts groups memberships ?

Get-ADPrincipalGroupMembership aSamAccountName
^ this help me to recover all groups.

but what would be a smart way to check the differences between two of those repsonse.

thank you in advance.

Toshi
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Erwin Pombett

ASKER

hello oBda,

thank you for your reply.

awsome !

can you explain me a bit this line :  

Select-Object -Property @{n='Group'; e={$_.InputObject.Split('=,')[1]}}, @{n='User'; e={Switch ($_.SideIndicator) {'==' {'<Both>'}; '<=' {$User1}; '=>' {$User2};}}}

thanks .
Avatar of oBdA
oBdA

That takes the output of the Compare-Object and creates two "calculated properties", "Group" and "User".
For "Group", the DistinguishedName is split to retrieve only the name, and for "User", the SideIndicator property of the comparison result is used to determine if the group was found for both users, or just a single one (and if so, which one).