Share via

I am trying to add member in mail enabled security group using graph api, Is that possible?

Sourav Bhunia 31 Reputation points
2021-10-29T07:07:30.11+00:00

I was able to add or remove users from the mail-enabled security group using graph API. but suddenly it stopped working. I am getting an error that the mail-enabled group can not update.

Please refer your ms doc144787-teesolve2.png144826-tessolve1.png

Microsoft Security | Microsoft Graph

6 answers

Sort by: Most helpful
  1. JanardhanaVedham-MSFT 3,581 Reputation points
    2022-01-24T16:11:54.043+00:00

    Hi @Rakhesh Sasidharan , @Sourav Bhunia ,

    I would like to share the latest update on this. As per mentioned in this documentation, managing mail-enabled security groups through Microsoft Graph are currently not possible. Mail-enabled security groups cannot be modified by Microsoft Graph as they are owned by Exchange Online and hence these groups need to be managed via Exchange Online PowerShell. Also, the documentation issue in this Group resource type documentation page has already been corrected for mail-enabled security groups.

    167850-microsot-graph-api-mail-enabled-security-groups.jpg

    Note: I have also upvoted for your feature request on managing mail-enabled security groups using MS graph API.

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" , so that it will be useful for the other communinity users and kindly upvote it. If you have further questions about this answer, please click "Comment".

    Was this answer helpful?

    6 people found this answer helpful.

  2. Omar Khalil Admin 0 Reputation points
    2024-06-07T12:05:11.6966667+00:00

    For people wondering how to go around this, how I did it is by writing an Azure Functions PowerShell that can be triggered via API and under the hood it connects with exchange PS

    Was this answer helpful?


  3. Rakhesh Sasidharan 21 Reputation points
    2021-11-18T16:54:49.407+00:00

    I just got a reply today to the GitHub issue I raised. Turns out you could add users to mail enabled groups previously via Graph API, but that was a bug... which they've now fixed. Also, the documentation is incorrect so MS will be correcting that. :-/

    I raised a feature request for this here in case anyone wants to upvote.

    Was this answer helpful?

    0 comments No comments

  4. Rakhesh Sasidharan 21 Reputation points
    2021-11-11T07:23:19.613+00:00

    In case it helps anyone else... I have the luxury of falling back to ExO as I have creds for that too so I modified my code to do that. Here's a snippet:

    New-MgGroupMember -GroupId $dstGroupId -DirectoryObjectId $UserObj.Id
        if ($? -eq $false) { 
            Write-Warning "==> Error adding $member via Graph, failing back to ExO" 
            try {
                Add-DistributionGroupMember -Identity "$dstGroupName" -Member $UserObj.mail -Confirm:$false -BypassSecurityGroupManagerCheck -ErrorAction Stop
            } catch {
                Write-Error "==> Error adding $member via ExO" 
            }
        }
    

    This way I can keep my script working until this issue is fixed.

    Was this answer helpful?


  5. Rakhesh Sasidharan 21 Reputation points
    2021-11-10T11:41:53.933+00:00

    Just to add I too am facing the same issue and came across this post while Googling. Until the 20th of Oct the New-MgGroupMember cmdlet could add users to a mail enabled security group but now it fails.

    New-MgGroupMember -GroupId 4938ba57-5e96-4a3e-b069-a066dd194a55 -DirectoryObjectId b269b48d-afa4-49ed-a26e-d684531b62c7
    New-MgGroupMember_CreateExpanded1: Cannot Update a mail-enabled security groups and or distribution list.
    

    Either the docs are now incorrect and Graph API doesn't allow adding users to mail enabled security groups, or there's a bug. I've also raised this as a GitHub issue with the docs team.

    Was this answer helpful?


Your answer

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