Mar 02 2017 10:25 AM - edited Mar 06 2017 09:16 AM
Mar 02 2017 10:25 AM - edited Mar 06 2017 09:16 AM
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 working.
Set-unifiedgroup -identity testo365 -primarysmtpaddress test123O365@qqq.onmicrosoft.com
Can someone please provide your thoughts on this.
Jun 20 2018 12:53 AM
Hi Yahkoob
Thanks for this. And I figured this is why it doesn't change. However we would like it to display in lowercase as it's our company name and it's officially spelled lowercase. If you have a solution great. If not we have to live with it, like with many other "imperfections" :)
Jun 20 2018 01:21 AM
Jun 20 2018 07:25 AM
Worked like a charm, Sweet
Thx ever so much!
Jun 20 2018 07:34 AM
Hi Yahkoob,
I asked last year something like that and you answer me but what I really need is to change all O365-Groups which are have been created in the past (not my past) with the wrong email addresses something like this @abc.onmicrosoft.com, how could be posible to use your script but for all O365 and not only one or two. Thank you so much.
Best regards,
Luciano
Jul 24 2018 05:48 AM
Aug 30 2018 08:11 AM
Thanks Yahkoob!
All your steps worked for except the last one to remove the email address. For some reason I am not able to remove the old email address associated with the group. I have attached the command I am using and message that I am getting.
PS C:\WINDOWS\system32> Set-UnifiedGroup -Identity "xxxxxx - Technical" -EmailAddresses: @{Remove="xx@xxx.onmicrosoft.com"}
WARNING: The command completed successfully but no settings of 'xxx_23d3be76e5' have been modified.
Thanks for your help.
Sep 11 2018 04:31 AM
Nov 22 2018 01:40 PM
Hi There,
Yes there is a way that you can make that change. Please take a look at the PowerShell script below.
PowerShell ISE is strongly recommended. (Copy Paste as it is and Run)
cls
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Write-Output "======================================================="
Write-host "======== CONFIGURING O365 GROUP EMAIL ADDRESS =========" -foreground "yellow"
Write-Output "======================================================="
$oldEmail=read-host "Which O365 Group email address do you want to edit? Ex: group@domain.onmicrosoft.com"
$newEmail=read-host "Please enter the new email address for $oldEmail Ex: group@domain.com"
Set-Group -Identity $oldEmail -WindowsEmailAddress $newEmail
Write-Output "======================================================="
Write-host "=============== COMPLETED SUCCESSFULLY ================" -foreground "green"
Write-Output "======================================================="
Get-Group -Identity $newEmail | select display*,windows*
Once you run this scrript you will be asked to import to the module please choose yes to all to allow the necessary modules and then log in. After your log in you will be asked to provide the current email of the group and after that you will be asked to type the new email. Within 2 minutes the change will apply and you can see it on your EAC and please close your browser and re-open it and sign into Portal.office,com and the changes will appear under groups on Admin portal as well.
Jan 15 2019 10:58 AM
Very thank you! You save me!
Jan 31 2019 12:18 AM
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.
Jul 19 2019 02:54 PM
@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/
Dec 30 2019 01:56 PM
After looking through all the comments, I believe I may have found a slightly simpler method.
YourGroupName@YourTenantName.onmicrosoft.com - This is considered a MOERA address.
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
Jan 02 2020 12:46 PM
Generally speaking, site URL can now be edited via the SP Admin Center
Jan 02 2020 01:02 PM
Feb 03 2020 07:54 AM
@Yahkoob Ayappally Worked like a charm :) Nice, easy and simple to follow. Thank you.
Jun 12 2020 10:41 AM - edited Jun 12 2020 11:09 AM
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.
Jun 12 2020 11:13 AM
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.
Apr 21 2021 11:56 AM