How to change a Team email
There are a lot of reasons that can lead you to a rename of a Team, either because the self-creation is enabled, and the names don’t follow the internal rules or simply because the name no longer makes sense.
On Microsoft Teams you have a graphical interface that will allow you to change the name and the description of the Team however the email will not change to reflect the modification.
To modify the email, you will need to use the Exchange PowerShell below to create a new alias and delete the old one.
- Copy the code paste it on notepad and modify the variables to match your environment
- Save the file with the name changeMail.ps1
- Right click on the file and select run with PowerShell
- If asked type Y on the execution policy
- Enter your credentials and wait for the execution of the file
#Adjust variables $originalEmail = "formula1" $newEmail = "formula1-2019" $domain = "contoso.com" $office365domain = "contoso.onmicrosoft.com" $groupName = "Formula 1 2019" $removeOldEmail = $false #Login $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session -DisableNameChecking #SMTP Domain Set-UnifiedGroup -Identity $groupName -EmailAddresses: @{Add =("{0}@{1}" -f $newEmail, $domain)} Set-UnifiedGroup -Identity $groupName -PrimarySmtpAddress ("{0}@{1}" -f $newEmail, $domain) #Office 365 Domain Set-UnifiedGroup -Identity $groupName -EmailAddresses: @{Add =("{0}@{1}" -f $newEmail, $office365domain)} Set-UnifiedGroup -Identity $groupName -PrimarySmtpAddress ("{0}@{1}" -f $newEmail, $office365domain) #Remove the old email if ($removeOldEmail){ Set-UnifiedGroup -Identity $groupName -EmailAddresses: @{Remove=("{0}@{1}" -f $originalEmail, $domain)} Set-UnifiedGroup -Identity $groupName -EmailAddresses: @{Remove=("{0}@{1}" -f $originalEmail, $office365domain)} } Remove-PSSession $Session
Be careful when using this script, make sure you will not cause any disruption on your teams.
No comments yet