List all users in large group

Samuel 1 Reputation point
2022-05-13T18:56:12.493+00:00

I need to iterate over all the users in a large group (>700,000 users). A certain subset of my users created before a specific date are either missing properties that are now required or have some properties set incorrectly. I'm attempting to do this via REST calls out of a script I've written.

Running through the /groups/{id}/members API call I can confirm that Graph returns an invalid skipToken at around 700,000 users, which matches up with the graph connector API item limit shown here:

201922-image.png

And here's the response when I use the skipToken from the request that was successful:

{  
    "error": {  
        "code": "Request_UnsupportedQuery",  
        "message": "Unable to execute query; invalid page token specified.",  
        "innerError": {  
            "date": "2022-05-13T18:52:00",  
            "request-id": "{id}",  
            "client-request-id": "{id}"  
        }  
    }  
}  

I have tried filtering the users by createdDateTime le {yyyy-mm-ddT00:00:00Z} but it looks like Graph doesn't support that property for filtering:

{  
    "error": {  
        "code": "Request_UnsupportedQuery",  
        "message": "The specified filter to the reference property query is currently not supported.",  
        "innerError": {  
            "date": "2022-05-13T18:49:16",  
            "request-id": "{id}",  
            "client-request-id": "{id}"  
        }  
    }  
}  

I also know that some of the users I need to update don't have a specific property set, but it doesn't look like Graph supports filtering by a missing property either.

So, how can I get my invalid users from Azure?

TLDR: I'm running a script that makes REST calls to the Azure Graph API. I have users, created before a specific date, that are missing or have some invalid properties I need to update.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,646 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Zehui Yao_MSFT 5,831 Reputation points
    2022-05-16T10:50:44.74+00:00

    Hello @Samuel , per my test Indeed the /members endpoint does not support filter for filtering

    So far, one solution I can offer is to filter by https://graph.microsoft.com/v1.0/users?$select=id,displayName,createdDateTime&$filter= createdDateTime le yyyy-mm-ddT00:00:00Z for createdDateTime.

    Then use https://graph.microsoft.com/v1.0/users/7ecaa4ca-93a1-4208-b94f-da6c6882f7d6/memberof to determine whether the filtered users belong to your group.

    Finally get the users you want, hope this helps you


    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.