Search code examples
azureazure-active-directorysubdomain

AAD - how to change the email domain after creating a group


Using API Graph, I create an ADD group with an email address. The domain for the address is automatically added to the one that is primary in the tenant. I cannot change the default domain on the tenant, but I need to change the domain for the created group to a domain other than primary. How can I achieve this?


Solution

  • Note that, you cannot update mail-enabled security groups via Microsoft Graph as they are read-only via API. Alternatively, you can make use of Exchange Online commands in PowerShell.

    In my Azure AD tenant, I have couple of domains where one is Primary like this:

    enter image description here

    Now, I created one group named Sridemogroup that has Email with primary domain as below:

    enter image description here

    To change the email domain after creating a group, you can run below Exchange Online commands in PowerShell:

    Connect-ExchangeOnline
    Get-UnifiedGroup -Identity Sridemogroup
    Set-UnifiedGroup -Identity "Sridemogroup" -EmailAddresses @{Add ="[email protected]"}
    Set-UnifiedGroup -Identity "Sridemogroup" -PrimarySmtpAddress [email protected]
    Get-UnifiedGroup -Identity Sridemogroup
    

    Response:

    enter image description here

    When I checked the same in Portal, Email domain of group changed successfully as below:

    enter image description here