Microsoft Graph API - Get a list of all users with a specific license SKU

다언 이 6 Reputation points
2022-02-28T08:30:28.973+00:00

With Microsoft Graph API,

I want to get a list of users with a certain license such as O365 E3, Business Standard etc.

Get a user list
https://learn.microsoft.com/en-us/graph/api/user-list-licensedetails?view=graph-rest-1.0&tabs=http

Get a list of all allocated licenses of one user
https://learn.microsoft.com/en-us/graph/api/resources/user?view=graph-rest-1.0

What I want is, all the users' list hoding a certain license.

If it does not exist, I have to loop so many times which is low performance.

Please help. Thank you.
Daniel

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,779 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Sreeju Nair 11,621 Reputation points
    2022-02-28T08:41:08.54+00:00

    You can use graph api to list the users and add filter parameter to get the users who are assigned with a particular license. This use case is documented in the following URL.

    https://learn.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0&tabs=http#example-8-use-filter-to-get-users-who-are-assigned-a-specific-license

    GET https://graph.microsoft.com/v1.0/users?$select=id,mail,assignedLicenses&$filter=assignedLicenses/any(u:u/skuId eq cbdc14ab-d96c-4c30-b9f4-6ada7cdc1d46)  
    
    2 people found this answer helpful.