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 Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,337 questions
0 comments No comments
{count} votes

Accepted answer
  1. Raja Pothuraju 5,010 Reputation points Microsoft Vendor
    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.


1 additional answer

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
    
    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.