Avatar of MilesLogan
MilesLoganFlag for United States of America asked on

Powershell - Comparing groups membership

I am trying to compare the group members of one group to multiple others.

Group1
Group2
Group3

Is there a way in Powershell for me to see if all the users in Group2,Group3 are members of Group1 ? ideally for it to output the SAmAccountNames of missing accounts that are in Group2 and Group3 that are not in Group1
PowershellActive DirectoryWindows Server 2003

Avatar of undefined
Last Comment
MilesLogan

8/22/2022 - Mon
Jon Covalt

Powershell includes a cmdlet called Compare-Object that you can use to accomplish this. You would need to first import the AD powershell tool and then use the Get-ADGroupMember cmdlet to pull the list of users from Group 2 and Group 3, then compare them to the members in Group 1. See the following for explanations of these cmdlets.

http://technet.microsoft.com/en-us/library/ee617193.aspx

http://technet.microsoft.com/en-us/library/ee156812.aspx
Subash Sundharan

You just want to verify if the members of Group2 & Group3 are also members of Group1.. Am I correct?
ASKER
MilesLogan

Hi Subsub .. yes
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
Subash Sundharan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
MilesLogan

Thank you Subsun !!