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
Avatar of Jon Covalt
Jon Covalt
Flag of United States of America image

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
Avatar of SubSun
SubSun
Flag of India image

You just want to verify if the members of Group2 & Group3 are also members of Group1.. Am I correct?
Avatar of MilesLogan
MilesLogan
Flag of United States of America image

ASKER

Hi Subsub .. yes
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of MilesLogan
MilesLogan
Flag of United States of America image

ASKER

Thank you Subsun !!
Windows Server 2003
Windows Server 2003

Windows Server 2003 was based on Windows XP and was released in four editions: Web, Standard, Enterprise and Datacenter. It also had derivative versions for clusters, storage and Microsoft’s Small Business Server. Important upgrades included integrating Internet Information Services (IIS), improvements to Active Directory (AD) and Group Policy (GP), and the migration to Automated System Recovery (ASR).

129K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo