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
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,819 questions
{count} votes

2 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 37,786 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.

  2. Brian McCullough 1 Reputation point

    Got it: