Dynamic approach for remove user licence Using Microsoft Graph API

Mithila Lishan 136 Reputation points
2024-03-23T08:51:49.2166667+00:00

I'm in the process of implementing the Microsoft Graph API for license upgrades. I've implemented the functionality to select a license to upgrade through a dropdown menu, with options such as P1, E1, F1, and E3. Once the user selects a license, I can determine its corresponding GUID and use the Microsoft Graph API to update the user's license.

However, I'm encountering confusion regarding removing existing licenses from the user. I've found no direct option to filter the user's current Office 365 licenses for removal. Now, I'm seeking advice on a dynamic approach to removing the user's existing licenses. Any suggestions would be greatly appreciated.

Microsoft Office Online Server
Microsoft Office Online Server
Microsoft on-premises server product that runs Office Online. Previously known as Office Web Apps Server.
586 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,632 questions
Microsoft Exchange Licensing
Microsoft Exchange Licensing
Microsoft Exchange: Microsoft messaging and collaboration software.Licensing: Rules, regulations, and restrictions that define how software can be used and distributed.
7 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 95,581 Reputation points MVP
    2024-03-23T21:10:09.21+00:00

    Not entirely sure what the ask is here? Can you please expand with additional details?

    You can fetch the set of currently assigned licenses for a given user via a standard GET request against the /users/{userid} endpoint, which does also support filtering by license, if needed. As for removing an assigned license, the operation is pretty much the same as assigning one, but you only need to provide the GUID. To remove all licenses, you need to list each individual GUID, there is no shortcut option. If you need more detailed instructions, I have a sample script here: https://github.com/michevnew/PowerShell/blob/master/Graph_Remove_all_licenses.ps1