SOLVED

Azure AD Dynamic Groups - Display Membership and count members

%3CLINGO-SUB%20id%3D%22lingo-sub-376944%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20Dynamic%20Groups%20-%20Display%20Membership%20and%20count%20members%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-376944%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F8291%22%20target%3D%22_blank%22%3E%40William%20Tait%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20just%20browse%20to%20the%20AAD%20group%20in%20Azure%20portal%20and%20get%20the%20Object%20ID%20from%20the%20Overview%20blade.%3C%2FP%3E%3CP%3EThen%20run%20the%20below%3A%3C%2FP%3E%3CP%3E%3CSPAN%3E(%3C%2FSPAN%3EGet-AzureADGroupMember%20-All%20%24true%20-ObjectId%20%22%3CSTRONG%3EGUID%20OF%20AAD%20GROUP%3C%2FSTRONG%3E%22%20%7C%20select%20mail).Count%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-70040%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20Dynamic%20Groups%20-%20Display%20Membership%20and%20count%20members%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-70040%22%20slang%3D%22en-US%22%3E%3CP%3EIt's%20a%20boolean%20parameter%2C%201%20equals%20%24true%20%3A)%3C%2Fimg%3E%20And%20don't%20get%20me%20started%20on%20the%20stupid%20syntax%20used%20by%20the%20AzureAD%20module%2C%20gotta%20love%20programmers...%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-69998%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20Dynamic%20Groups%20-%20Display%20Membership%20and%20count%20members%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-69998%22%20slang%3D%22en-US%22%3EYes%2C%20that%20works.%20Documentation%20doesn't%20explain%20why%20without%20-ALL%20the%20limit%20is%20100.%3CBR%20%2F%3E%3CBR%20%2F%3EAwkward%20syntax%20but%20it%20works%3A%3CBR%20%2F%3E(Get-AzureADGroup%20-ALL%201%20-Filter%20%22DisplayName%20eq%20'GroupName'%22%20%7C%20Get-AzureADGroupMember%20-ALL%201).COUNT%3CBR%20%2F%3E%3CBR%20%2F%3EThanks.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-69739%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20Dynamic%20Groups%20-%20Display%20Membership%20and%20count%20members%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-69739%22%20slang%3D%22en-US%22%3E%3CP%3ETry%20the%20-All%20parameter%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1012792%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20Dynamic%20Groups%20-%20Display%20Membership%20and%20count%20members%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1012792%22%20slang%3D%22en-US%22%3EYou%20could%20also%20leverage%20the%20following%20with%20the%20new%20Az%20module%20to%20simply%20get%20the%20count%20similar%20to%20some%20of%20the%20other%20versions%20recommended%20here%20in%20this%20post.%3CBR%20%2F%3E%3CBR%20%2F%3E(Get-AzADGroup%20-DisplayName%20%22%3CDISPLAYNAMEOFGROUP%3E%22%20%7C%20Get-AzADGroupMember).count%3C%2FDISPLAYNAMEOFGROUP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1273625%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20Dynamic%20Groups%20-%20Display%20Membership%20and%20count%20members%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1273625%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F58%22%20target%3D%22_blank%22%3E%40Vasil%20Michev%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20about%20the%20-All%20parameter%20in%20case%20of%20Office%20365%20groups%3C%2FP%3E%3CTABLE%20width%3D%22929%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%22146%22%3ELDAP%20display%20name%3C%2FTD%3E%3CTD%20width%3D%22157%22%3EAvailable%20on%20cmdlets%3C%2FTD%3E%3CTD%20width%3D%2254%22%3EValue%3C%2FTD%3E%3CTD%20width%3D%22572%22%3EComments%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22146%22%3En%2Fa%3C%2FTD%3E%3CTD%20width%3D%22157%22%3EGet-UnifiedGroup%3C%2FTD%3E%3CTD%20width%3D%2254%22%3EInteger%3C%2FTD%3E%3CTD%20width%3D%22572%22%3EFor%20example%2C%26nbsp%3BGet-UnifiedGroup%20-Filter%20%22GroupExternalMemberCount%20-gt%200%22.%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFilterable%20properties%20for%20the%20Filter%20parameter%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fexchange%2Fexchange-server%2Frecipient-filters%2Ffilter-properties%3Fview%3Dexchange-ps%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fexchange%2Fexchange-server%2Frecipient-filters%2Ffilter-properties%3Fview%3Dexchange-ps%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E-All%20parameter%20-%20when%20used%20the%20command%20does%20not%20generate%20any%20output%2C%3C%2FP%3E%3CP%3Ebut%20it%20works%20without%20but%20then%20not%20sure%20if%20it%20was%20able%20to%20check%2Ftraverse%2Fenumerate%20all%20groups%20or%20not%20%2C%3C%2FP%3E%3CP%3EAs%20in%20just%20the%20first%20100%20or%20something%20when%20-All%20or%20unlimited%20is%20not%20specified%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBR%2C%3C%2FP%3E%3CP%3E%2FHS%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-69657%22%20slang%3D%22en-US%22%3EAzure%20AD%20Dynamic%20Groups%20-%20Display%20Membership%20and%20count%20members%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-69657%22%20slang%3D%22en-US%22%3E%3CP%3ECreated%20Azure%20AD%20Dynamic%20Groups.%20These%20Groups%20have%20thousands%20of%20members.%20The%20Azure%20Portal%20GUI%20will%20show%20the%20group%20as%20having%20%221000%2B%20Members%22.%20Drilling%20into%20this%20Dynamic%20group%20will%20display%20the%20following%20message%3A%20%22Group%20members%20cannot%20be%20shown%20for%20this%20group.%20This%20group%20has%20more%20than%201000%20members%22.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3ESo%20if%20I%20attempt%20to%20get%20the%20membership%20from%20this%20group%20using%20the%20following%20Powershell%3A%3C%2FDIV%3E%3CP%3Eget-azureadgroup%20-SearchString%20%22GroupName%22%20%7C%20Get-AzureADGroupMember%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20results%20show%20100%20members.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGetting%20a%20count%20also%20shows%20100%20members.%26nbsp%3B%3C%2FP%3E%3CP%3E(get-azureadgroup%20-SearchString%20%22GroupName%22%20%7C%20Get-AzureADGroupMember).COUNT%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAppears%20to%20be%20a%20limit%20on%20the%20results%20returned.%20How%20can%20I%20display%20all%20the%20members%20in%20a%20Dynamic%20Group%20and%20get%20a%20proper%20count%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-69657%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20AD%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Contributor

Created Azure AD Dynamic Groups. These Groups have thousands of members. The Azure Portal GUI will show the group as having "1000+ Members". Drilling into this Dynamic group will display the following message: "Group members cannot be shown for this group. This group has more than 1000 members". 

 

So if I attempt to get the membership from this group using the following Powershell:

get-azureadgroup -SearchString "GroupName" | Get-AzureADGroupMember

 

The results show 100 members.

 

Getting a count also shows 100 members. 

(get-azureadgroup -SearchString "GroupName" | Get-AzureADGroupMember).COUNT

 

Appears to be a limit on the results returned. How can I display all the members in a Dynamic Group and get a proper count? 

 

7 Replies
best response confirmed by William Tait (Contributor)
Solution

Try the -All parameter?

Yes, that works. Documentation doesn't explain why without -ALL the limit is 100.

Awkward syntax but it works:
(Get-AzureADGroup -ALL 1 -Filter "DisplayName eq 'GroupName'" | Get-AzureADGroupMember -ALL 1).COUNT

Thanks.

It's a boolean parameter, 1 equals $true :) And don't get me started on the stupid syntax used by the AzureAD module, gotta love programmers...

@William Tait 

I would just browse to the AAD group in Azure portal and get the Object ID from the Overview blade.

Then run the below:

(Get-AzureADGroupMember -All $true -ObjectId "GUID OF AAD GROUP" | select mail).Count

You could also leverage the following with the new Az module to simply get the count similar to some of the other versions recommended here in this post.

(Get-AzADGroup -DisplayName "<DisplayNameofGroup>" | Get-AzADGroupMember).count

@Vasil Michev 

What about the -All parameter in case of Office 365 groups

LDAP display nameAvailable on cmdletsValueComments
n/aGet-UnifiedGroupIntegerFor example, Get-UnifiedGroup -Filter "GroupExternalMemberCount -gt 0".

 

Filterable properties for the Filter parameter
https://docs.microsoft.com/en-us/powershell/exchange/exchange-server/recipient-filters/filter-proper...

 

-All parameter - when used the command does not generate any output,

but it works without but then not sure if it was able to check/traverse/enumerate all groups or not ,

As in just the first 100 or something when -All or unlimited is not specified

 

BR,

/HS

 

 

@Himanshu Singh hi!!!

 

less complex (Get-AzureADGroupMember -all 1 -ObjectId "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").count