List AAD Groups with membership count

Brian McCullough 1 Reputation point

Is there a way to get a list of AAD groups with membership count? With Graph API? Even if ConsistencyLevel=Eventual?

Like: /groups?$filter=startsWith(displayName,'MYPREFIX-WHATEVS')&$select=displayName,members/$count

Microsoft Graph Groups API
Microsoft Graph Groups API
A Microsoft API that creates and manages different types of groups and group functionality.
204 questions
{count} votes

2 answers

Sort by: Newest
  1. Brian McCullough 1 Reputation point

    Got it:


  2. CarlZhao-MSFT 23,031 Reputation points

    Hi dear @Brian McCullough

    There is something wrong with your API, because members is actually an expansion item and not a child item, so your API should be changed to: /groups?$filter=startsWith(displayName,'MYPREFIX-WHATEVS')&$select=displayName&$expand=members.

    Since the expansion parameter $expand and the count parameter $count cannot be used together, your original API should remove the members parameter:

      ConsistencyLevel: eventual  

    Or only count the number of members of a certain group:{group object id}/members?$filter=startsWith(displayName,'MYPREFIX-WHATEVS')&$select=displayName,id&$count=true  
    ConsistencyLevel: eventual  

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.