Thursday, July 25, 2013

Active Directory - Find Difference Between Group Membership For User

While getting access transferred from one user to another, you may need to know how the group memberships are different between two users.
Import-Module ActiveDirectory

$leaving = Get-ADUser -Identity John.Doe -Properties memberof | select -expand memberof
$promoted = Get-ADUser -Identity Michael.West -Properties memberof | select -expand memberof

Compare-Object -ReferenceObject $promoted -DifferenceObject $leaving