Forum Discussion
Deleted
Mar 02, 2017Is there a way to change O365 group email address using powershell
My organization wants to change email address of O365 group. I am not able to find any power shell to change email address of already created O365 group. I tried below command but it is not workin...
- 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"}
John Karlovich
Oct 17, 2017Copper Contributor
"
Yahkoob Ayappally wrote:
If 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"}
If I use that command, I get the following error:
There are multiple primary SMTP addresses. Please ensure there is only one primary address for each address type."
Yahkoob Ayappally
Oct 19, 2017Brass Contributor
Hi John,
Steps to change Office 365 group Email address:-
Current SMTP address :- test.o365group@abcd.onmicrosoft.com
Required SMTP address :- test.o365group@abcd.com
Follow the below steps in power shell using Global Administrator Credentials,
1. Connect to Exchange Online via Power shell using Global Administrator Credentials and run the below commends. First two command run separately.
Set-ExecutionPolicy Unrestricted
Start-service winrm
Import-module MSOnline
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Connect-MsolService -Credential $UserCredential
2. Run the below command to add required SMTP address as an alias.
Set-UnifiedGroup -Identity "X" -EmailAddresses: @{Add ="Y"}
here X is the Display Name of Office 365 group and Y is the required Email ID.
Set-UnifiedGroup -Identity "Test o365Group" -EmailAddresses: @{Add ="test.o365group@abcd.com"}
3. Promote alias as a primary SMTP address,
Set-UnifiedGroup -Identity "Test O365Group" -PrimarySmtpAddress "test.o365group@abcd.com"
4. If not required, you can remove first ID using below command.
Set-UnifiedGroup -Identity "Test o365Group" -EmailAddresses: @{Remove="test.o365group@abcd.onmicrosoft.com"}
Please note, For updating the Office 365 group SMTP address required Global Administrator access.
Thanks and Regards,
Yahkoob Ayappally
- Luuka_AlexanderFeb 03, 2020Copper Contributor
Yahkoob Ayappally Worked like a charm 🙂 Nice, easy and simple to follow. Thank you.
- Likun ChenJul 19, 2019Copper Contributor
Yahkoob Ayappally Thank you.
To all others, notice this method won't change the URL of group's SharePoint site.
There seems to be a pilot program to let you rename sp site's url. The latest sp shell cmdlet also includes `Start-SPOSiteRename` command. But for now, we are still at the mercy of MicroSoft to make it available.
https://office365itpros.com/2019/05/02/sharepoint-online-rename-site-names/
- pnthrzruleJan 02, 2020Iron Contributor
Generally speaking, site URL can now be edited via the SP Admin Center
- Likun ChenJan 02, 2020Copper ContributorThank you pnthrzrule. Just changed the url in thew new SP admin center.
- pnthrzruleDec 30, 2019Iron Contributor
After looking through all the comments, I believe I may have found a slightly simpler method.
- The following example is assuming that your current Office 365 Group email address looks something like this:
YourGroupName@YourTenantName.onmicrosoft.com - This is considered a MOERA address.
- The example is also assuming that when you replace the existing email address that you are going to replace it with a custom domain address like this:
YourNewAddress@contoso.com
Here we go!
1. You can start right away with adding a primary SMTP by using this:
Set-UnifiedGroup -Identity "Your Group Name" -PrimarySmtpAddress YourNewAddress@contoso.com
The step above should automatically replace your current primary SMTP address and move the current primary address into an alias slot. You can verify this by going into the Office 365 Admin Center (make sure you refresh it) and viewing the group settings. Also, "contoso.com" in the step above refers to your custom domain address.
2. Now if you want to remove the old primary address which is now an alias (it's the alias with .onmicrosoft.com in the name), you will need to run a combination add/remove command based on the -EmailAddresses cmdlet. Basically your primary address was most likely a MOERA address like - YourGroupName@YourTenantName.onmicrosoft.com. And according to what I've tried, Microsoft requires that either your Primary address or one of your Aliases have *.onmicrosoft.com in the address. To accomplish this you can run...
Set-UnifiedGroup -Identity "Group Name" -EmailAddresses @{add="YourNewAddress@YourTenatName.onmicrosoft.com";remove="YourOldAddress@YourTenantName.onmicrosoft.com"}
Please note: the Curly brackets or Braces in the command above are meant to be included in the script
So to recap if you have only one Office 365 Group email address (no aliases) and you want to replace the current address
1. Add a primary address with your custom domain using -PrimarySmtpAddress
2. Add a new .onmicrosoft.com alias and remove the old one in the same command using -EmailAddresses
- Corey RichardsonJun 12, 2020Copper Contributor
You can use the following method to change the PrimarySMTPAddress of many groups at once.
First, 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.
Get-UnifiedGroup -Filter {DisplayName -like "O365Test*"}
Once you have your list, pipe it into a Foreach-Object loop and apply the new PrimarySMTPAddress like this - see my note below about my concerns with this before proceeding.
Get-UnifiedGroup -Filter {DisplayName -like "O365Test*"} | Foreach-Object { Set-UnifiedGroup -Identity $_.Name -PrimarySmtpAddress "$($_.Alias)@groups.domain.com"}
I'm not a PowerShell expert. So please, test in a lab!!!
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.
- nattusrattusJan 31, 2019Copper Contributor
Thanks this worked perfectly. I did have to wait a couple of minutes between commands though for them to be fully actioned on o365, running them immediately gave errors.
- Leandro FulyJan 15, 2019Copper Contributor
Very thank you! You save me!
- DeletedMar 08, 2018
Thanks for share! works for me amazingly!
- Yahkoob AyappallyMar 11, 2018Brass Contributor
cool always welcome Howard :)
- DeletedJun 19, 2018
works like a charm so Thx, one thing it doesn't seem to do I want to change from Capitals to lowercase
WORD@mail.com to word@mail.com
any advice/suggestions?
- DeletedJan 30, 2018Worked for me, thanks!
- Rutger AaltinkJan 03, 2018Copper ContributorThank you for the post. This worked like a charm.
- Yahkoob AyappallyJan 03, 2018Brass Contributor
good to know that :)
- DeletedDec 05, 2017
Hi, I have a question, I would like to change all existing O365 Groups which have a wrong e-mail address:
Get-UnifiedGroup -Filter {EmailAddresses -like '*@abd.onmicrosoft.com'} | Set-UnifiedGroup -PrimarySmtpAddress but I Need some variable for the Name before the @, do you have an Idea?
Thanks and best regards,Luciano
- Yahkoob AyappallyDec 06, 2017Brass Contributor
Hai Luciano,
Good Day.
Yes It is possible, you can add new email ID and you can promote your new Email ID as an SMTP and you can remove your Old Email ID. But performing this steps, you need a global Administrator access.
Please follow below Steps to change Office 365 group Email address:-
Current SMTP address :- test.o365group@abcd.onmicrosoft.com
Required SMTP address :- test.o365group@abcd.com
Follow the below steps in power shell using Global Administrator Credentials,
1. Connect to Exchange Online via Power shell using Global Administrator Credentials and run the below commends. First two command run separately.
Set-ExecutionPolicy Unrestricted
Start-service winrm
Import-module MSOnline
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Connect-MsolService -Credential $UserCredential2. Run the below command to add required SMTP address as an alias.
Set-UnifiedGroup -Identity "X" -EmailAddresses: @{Add ="Y"}
here X is the Display Name of Office 365 group and Y is the required Email ID.
Eg:- Set-UnifiedGroup -Identity "Test o365Group" -EmailAddresses: @{Add ="test.o365group@abcd.com"}
3. Promote alias as a primary SMTP address,
Set-UnifiedGroup -Identity "Test O365Group" -PrimarySmtpAddress "test.o365group@abcd.com"
4. If not required, you can remove first ID using below command.
Set-UnifiedGroup -Identity "Test o365Group" -EmailAddresses: @{Remove="test.o365group@abcd.onmicrosoft.com"}
Please note, For updating the Office 365 group SMTP address required Global Administrator access.Hope this will help you and let me know if you are facing any issue on this.
Thanks and Regards,
Yahkoob Ayappally
- Dec 14, 2017This works good in principle, using Set-UnifiedGroup to change primary SMTP address, and adding and removing addresses from the EmailAddresses, like in Yahkoob's examples. The unfortunate thing though, if you try to remove an e-mail address, it will not be removed from the Azure AD Group/Exchange group object. You will still see the e-mail address you tried to remove as one of the aliases for the group if you look at the group in the Office 365 Admin portal, or if you look at the proxy addresses using Get-AzureADGroup, Get-AzureADMSGroup or Get-MSOLGroup. There is currently no way you can remove an e-mail address from these groups, so there is an discrepancy between using Set-UnifiedGroup and the group object represented in Exchange Online or Azure AD. Unfortunately, recently I discovered that this proxy addresses also is written back to local AD if you configure Azure AD Connect Group Writeback. This could possibly lead to conflict with local Exchange recipients using the same emailaddress. There really should be a way to remove emailaddresses from Office 365 Groups all the way to prevent conflicts.
- Ryan SalaheddineOct 27, 2017Brass ContributorThank you for the post. This worked like a charm. The only thing is the typo "}" that you have in step 3. Everything else works great.
- Yahkoob AyappallyOct 29, 2017Brass ContributorDear Ryan,
Good Day.
Yes, Thanks for notifying. its typo error, mistakenly added :)