Add/Remove user from a Mail Enabled Security Azure AD group

Anonymous
2023-01-02T10:45:42.007+00:00

While trying to Add/Remove user from a Mail Enabled Security Azure AD group, not able to perform the the action. Getting exception as:
"Response Code - 400 Error - Cannot Update a mail-enabled security groups and or distribution list."
We are trying to use Microsoft Graph API to Add/Remove a user from a mail-enabled Azure AD group.

Exchange Exchange Server Management
0 comments No comments
{count} vote

3 answers

Sort by: Most helpful
  1. Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
    2023-01-02T10:51:44.797+00:00

    Mail-enabled security groups are Exchange Online objects, as such they cannot be managed via the Azure AD tools or the Graph API. Use the Exchange admin center or Exchange Online PowerShell to make the changes.

    0 comments No comments

  2. Martin Dimovski 1,636 Reputation points MVP
    2023-01-02T10:52:04.583+00:00

    Hi,

    Thank you for posting the question to the Q&A forum.

    The graph cannot update mail-enabled security groups or distribution groups. It was a bug that is now fixed. You can up-vote this feature request below and maybe the Graph team will look into adding it.. The only thing you can do is use the Add-DistributionGroupMember command for distro lists.

    https://techcommunity.microsoft.com/t5/microsoft-365-developer-platform/allow-addition-of-members-to-mail-enabled-security-groups-via/idi-p/2981455

    Mail-enabled security groups can't be created through the API, but other group operations work. Mail-enabled security groups are read-only.

    Mail-enabled security groups can be managed via Exchange. You can find more details on this here: https://learn.microsoft.com/en-us/Exchange/recipients/mail-enabled-security-groups?redirectedfrom=MSDN&view=exchserver-2019

    I hope the above information can help you.

    If the ANSWER is helpful, please click "Accept Answer" and upvote it. Thanks


  3. Aholic Liang-MSFT 13,886 Reputation points Microsoft External Staff
    2023-01-03T02:34:26.277+00:00

    Hi @Anonymous ,
    You could refer to the following commands to create / remove a mail-enabled security group:

    New-DistributionGroup -Name "File Server Managers" -Alias fsadmin -Type security  
    Remove-DistributionGroup -Identity " File Server Managers "  
    

    Then you could refer to the following command to verity that you've successfully created a mail-enabled security group:

    Get-DistributionGroup <Name> | Format-List Name,RecipientTypeDetails,PrimarySmtpAddress  
    

    More information for your reference:
    Manage mail-enabled security groups in Exchange Online | Microsoft Learn
    New-DistributionGroup (ExchangePowerShell) | Microsoft Learn
    Remove-DistributionGroup (ExchangePowerShell) | Microsoft Learn


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.