How to remove multiple licenses from a security group when licenses depend on each other

Jeff Lamb 36 Reputation points
2024-08-26T23:43:07.8833333+00:00

I have a security group that has two licenses assigned. These licenses are dependent on each other:

  • Microsoft Teams Domestic and International Calling Plan
  • Microsoft Teams Phone Resource Account

Ultimately, I want to delete the group. Here are the problems I'm facing:

  • Cannot delete the group because licenses are assigned
  • Cannot remove the D&I calling plan license because the other license relies on this one being assigned
  • Cannot remove the Phone Resource Account license because the D&I calling plan relies on it.
  • There is no facility in Entra Admin Center (that I can find) to remove multiple licenses at a time.

What is the solution to delete this group?

Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} votes

Accepted answer
  1. Raja Pothuraju 23,465 Reputation points Microsoft External Staff Moderator
    2024-08-29T20:19:20.31+00:00

    Hello @Jeff Lamb,

    Thank you for posting your query on Microsoft Q&A.

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.

    Issue: How to remove multiple licenses from a security group when licenses depend on each other

    Solution: Resolved by @Jeff Lamb.

    # Define the group ID to remove licenses from
    $groupId = "3343fcff-a8a5-4b70-9543-48c3cad059b3"
    $group = Get-MgGroup -GroupId $groupId -Property AssignedLicenses
    $licensesToRemove = $group.AssignedLicenses.SkuId
    
    # Create the parameters for the cmdlet
    $params = @{
        addLicenses = @()  # Empty array for addLicenses
        removeLicenses = $licensesToRemove
    }
    
    Set-MgGroupLicense -GroupId $groupId -BodyParameter $params
    
    

    If you have any other questions or are still running into more issues, please let me know. Thank you again for your time and patience throughout this issue.

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    Thanks,
    Raja Pothuraju.


2 additional answers

Sort by: Most helpful
  1. Jeff Lamb 36 Reputation points
    2024-08-26T23:51:44.0933333+00:00

    I figured it out with the MGGraph module:

    # Define the group ID to remove licenses from
    $groupId = "3343fcff-a8a5-4b70-9543-48c3cad059b3"
    $group = Get-MgGroup -GroupId $groupId -Property AssignedLicenses
    $licensesToRemove = $group.AssignedLicenses.SkuId
    
    # Create the parameters for the cmdlet
    $params = @{
        addLicenses = @()  # Empty array for addLicenses
        removeLicenses = $licensesToRemove
    }
    
    Set-MgGroupLicense -GroupId $groupId -BodyParameter $params
    

  2. Rick Angel 216 Reputation points
    2025-03-26T20:54:43.3966667+00:00

    I kept running into issues so I opened a support case. Here was the final solution.

    Below is a summary of your support request #2502250040009493

    Issue Description:

    How to remove distribution groups when Exchange is no longer in the tenant?

    Discussed Resolution:

    We ran the PowerShell cmdlets below to remove the distribution groups

    Install-Module Microsoft.Graph -Force
    
    Connect-MgGraph -Scopes "EntitlementManagement.ReadWrite.All","Group.ReadWrite.All"
    
    Get-MgApplication
    
    Connect-MgGraph -Scopes "User.Read","Application.Read.All"
    
    Remove-MgGroup -GroupId 'f6b9791b-dfc1-40d6-9ab6-7b29126c534a'
    

    We used the PowerShell cmdlets below to remove the licenses from the security groups

    Import-Module Microsoft.Graph.Groups
    
             $groupId = "your-group-id"
    
            $skuId = "f30db892-07e9-47e9-837c-80727f46fd3d"
    
            Set-MgGroupLicense -GroupId $groupId -AddLicenses @() -RemoveLicenses @($skuId)
    
    0 comments No comments

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.