You can get the list of ODFB site (collections) via the LIST sites method (requires app permissions), then correlate it to the list of licensed users. There's also a built-in report within the SPO admin center, but unfortunately Microsoft has not exposed any method to get to it programmatically.
Unlicensed OneDrive
Hi,
Has anyone found a way to undentiy unlicensed OneDrive accounts via Graph. Looking at these changes https://learn.microsoft.com/en-us/sharepoint/unlicensed-onedrive-accounts It would be great to identify what is about to be deleted.
Cheers
Josh
Microsoft Security | Microsoft Graph
2 answers
Sort by: Most helpful
-
Vasil Michev 124.7K Reputation points MVP Volunteer Moderator2024-11-06T07:22:48.34+00:00 -
Anonymous
2024-11-06T02:31:22.89+00:00 Hello JH,
Thank you for reaching out to Microsoft Support!
You can use the List users endpoint to list unlicensed users as follows:
However, other types of unlicensed OneDrive accounts are not listed, so it is recommended that you Get reports on unlicensed OneDrive accounts in the SharePoint admin center.
Reports can also be obtained through the Graph Api, but there is no endpoint to implement this functionality, see the documentation for details.
https://graph.microsoft.com/v1.0//users?$filter=assignedLicenses/$count eq 0&$count=true&$select=displayName,assignedLicenses ConsistencyLevel: eventualHope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.