Dynamic approach for remove user licence Using Microsoft Graph API

Mithila Lishan 71 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.
647 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,241 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.
23 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 107.7K 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


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.