how to revoke license

Rising Flight 5,036 Reputation points
2025-05-09T05:21:07.8166667+00:00

Hi All

I have a list of users who were directly assigned the Power Apps Premium license. I want to revoke their licenses. Can anyone please guide me with the PowerShell syntax? What is the correct syntax to connect to Graph PowerShell? After running Connect-MgGraph, do I need to grant any specific permissions? Also, what is the SkuPartNumber and skuid for the Power Apps Premium license? will the below syntax work. i have my txt file in the below format.

txt

$x=Get-Content "C:\temp\list.txt"
$powerappspremium = Get-MgSubscribedSku -All | Where SkuPartNumber -eq 'Power Apps premium'
for ($i=0; $i -lt $x.Count; $i++)
{
Set-MgUserLicense -UserId $x[$i] -RemoveLicenses @($powerappspremium.SkuId)
}

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
24,615 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Kancharla Saiteja 4,355 Reputation points Microsoft External Staff Moderator
    2025-05-09T15:42:20.7266667+00:00

    Hi @Rising Flight,

    Based on your query, here is my understanding: You would like to revoke user licenses using Mg graph.

    As per your query, here is the Microsoft document to add or remove licenses for user using Microsoft graph PowerShell: Set-MgUserLicense.

    Permission type Permissions (from least to most privileged)
    Delegated (work or school account) LicenseAssignment.ReadWrite.All, User.ReadWrite.All, Directory.ReadWrite.All,
    Delegated (work or school account) LicenseAssignment.ReadWrite.All, User.ReadWrite.All, Directory.ReadWrite.All,
    Delegated (personal Microsoft account) Not supported
    Application LicenseAssignment.ReadWrite.All, User.ReadWrite.All, Directory.ReadWrite.All,

    Here is the Microsoft document to find SKUs for the licenses: Product names and service plan identifiers for licensing

     User's image

     I hope this information is helpful. Please feel free to reach out if you have any further questions.

    If the answer is helpful, please click "Accept Answer" and kindly "upvote it". If you have extra questions about this answer, please click "Comment".


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.