Forum Discussion
Is there a way to change O365 group email address using powershell
- Oct 12, 2017If you want to update the Email Address of the Office 365 group, please follow below steps.
O365 Group Name :- Test O365Group
Current Email addres :- test.o365@abcd.onmicrosoft.com
Update to :- test.o365@abcd.com
Follow below script in powershell.
Set-UnifiedGroup -Identity "Test O365Group" -EmailAddresses: @{add="SMTP:test.o365@abcd.com"}
You can use the following method to change the PrimarySMTPAddress of many groups at once. You may want to use a -Filter to define a list of groups rather than applying this to ALL groups. In my case I used a list of test groups filtering them by DisplayName before applying this to all of my groups.
Get-UnifiedGroup -Filter {DisplayName -like "O365Test*"}
Then pipe it into a Foreach-Object loop and apply the new PrimarySMTPAddress.
Get-UnifiedGroup -Filter {DisplayName -like "O365Test*"} | Foreach-Object { Set-UnifiedGroup -Identity $_.Name -PrimarySmtpAddress "$($_.Alias)@groups.domain.com"}
We only had a couple dozen Office 365 Groups so I applied the new PrimarySMTPAddress globally.
Get-UnifiedGroup | Foreach-Object { Set-UnifiedGroup -Identity $_.Name -PrimarySmtpAddress "$($_.Alias)@groups.domain.com"}
A little background as to how I landed here... We have an Exchange Hybrid deployment with Centralized Mail Flow, on premise. This is because we have services on prem for compliance, archiving, signatures, mailing lists, marketing, etc. Our MX record points to our Exchange Server (well, actually our Barracuda ESG). We have an Edge server which is explicitly used for mail flow between On Prem and Exchange Online to avoid the need to expose our Exchange Server's SMTP to the internet (we were advised not to place the Barracuda between Exchange Server and Exchange Online mail flow, that's why there's an Edge server). The Edge server works great as long as it's NOT an Office 365 Group. Emailing O365 Groups (or Teams) from any on-prem Mailbox resulted in a Mail Loop. After investigation, it was revealed Exchange Hybrid doesn't know how to handle Office 365 groups, even with Group Writeback enabled. I tried modifying the "targetAddress attribute of the group (since we have Group Writeback enabled) in Active Directory with no success. However, updating the PrimarySMTPAddress of the Group to our tenent.onmicrosoft.com domain worked perfectly. It was determined our Exchange Server simply routes emails destined for these groups to the internet, ignoring any Send Connectors configured for Exchange Hybrid. I have no idea why this occurs, but a consultant was able to recreate this behavior. For now, we decided to create a groups domain, groups.domain.com, and add it as an accepted InternalRelay domain on-prem. I also created an Email Address Policy in Exchange Online for any future groups that are created. Unfortunately this didn't update any of the existing Groups. And that's how I landed here. Posting in case anyone else needs this info. Cheers.
https://docs.microsoft.com/en-us/exchange/hybrid-deployment/set-up-office-365-groups?redirectedfrom=MSDN
https://docs.microsoft.com/en-us/microsoft-365/admin/create-groups/choose-domain-to-create-groups?view=o365-worldwide