Monday, 4 December 2017

Change Office 365 Group Email Address using PowerShell

Modifying name or display name of Office 365 Group is simple. However, if you want to rename primary email address this is simply not possible from Admin center, but we can easily change it using the Exchange Online Powershell cmdlet Set-UnifiedGroup.

Note: Before proceed, Connect Exchange Online Remote PowerShell.

Rename Primary E-mail Address of Office 365 Group

We need to use the attribute PrimarySmtpAddress in Set-UnifiedGroup cmdlet to change the primary mail address of an O365 group. The below command change the primary address to for the group named "Sales Group".
Set-UnifiedGroup -Identity "Sales Group" -PrimarySmtpAddress ""

Rename Group Alias or Email Alias

To update email alias we need to update the attribute alias. The below command rename the mail alias to salesgroupnew.
Set-UnifiedGroup -Identity "Sales Group" -Alias "salesgroupnew"

Add or Remove Secondary Email Addresses (or Proxy Addresses)

We can use the parameter EmailAddresses in Set-UnifiedGroup cmdlet to update proxy addresses of office 365 group. The EmailAddresses parameter specifies all the email addresses (proxy addresses) for the recipient, including the primary SMTP address.

Syntax to update email addresses:
Set-UnifiedGroup -Identity "o365group" -EmailAddresses @{Add="[<Type>]:<emailaddress1>","
The optional value <Type> specifies the type of email address. Some of valid values are:
  • SMTP - The primary SMTP address (You can use this value only once in a command).
  • smtp - Other SMTP email addresses.
If you don't include a <Type> value for an email address, the value smtp (proxy address) is assumed.

Add proxy address:
Set-UnifiedGroup -Identity "Sales Group" -EmailAddresses @{Add="",
Remove proxy address:
Set-UnifiedGroup -Identity "Sales Group" -EmailAddresses @{Remove="",
To add or remove proxy addresses without affecting other existing values, use the following syntax.
Set-UnifiedGroup -Identity "Sales Group" -EmailAddresses @{Add="",
""; Remove="",""}

Change both Primary and Secondary Email Address in single command

We can easily update both primary and proxy address in a single command by specifying valid <Type> values (SMTP - for primary address. smtp - for proxy address).The following command removes the primary address and the proxy address, and adds the primary address and the proxy address
Set-UnifiedGroup -Identity "Sales Group" -EmailAddresses @{Remove="",
""; Add="",""; }

Export Email Address details of Office 365 group

We can use the following command to find and list the email address details for the given office 365 group.
Get-UnifiedGroup -Identity "Sales Group" | Select PrimarySMTPAddress,Alias,EmailAddresses|FL
The below command export email address details of all the office 365 groups to csv file.
Get-UnifiedGroup -ResultSize Unlimited | Select DisplayName,PrimarySMTPAddress,Alias,EmailAddresses |
Export-CSV "C:\\O365GroupMailAddresses.csv" -NoTypeInformation -Encoding UTF8


No comments:

Post a Comment