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?
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:
Now, I created one group named Sridemogroup
that has Email with primary domain as below:
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:
When I checked the same in Portal, Email domain of group changed successfully as below: