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.

Summary:

Changing email address of office 365 group includes the following four kind of tasks.
  • Rename Primary SMTP Address.
  • Rename Group Alias (or Email Alias).
  • Add or Remove Secondary Email Addresses (or Proxy Addresses).
  • Change both Primary and Secondary Email Address in single command
  • Find and Export Email Address details

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 salesgroupnew@domain.com for the group named "Sales Group".
Set-UnifiedGroup -Identity "Sales Group" -PrimarySmtpAddress "salesgroupnew@domain.com"

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>","
[<Type>]:<emailaddress2>"...;Remove="[<Type>]:<emailaddress3>","[<Type>]:<emailaddress4>"...}
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="salesgroup1@domain.com",
"salesgroup2@domain.com"}
Remove proxy address:
Set-UnifiedGroup -Identity "Sales Group" -EmailAddresses @{Remove="salesgroup3@domain.com",
"salesgroup4@domain.com"}
To add or remove proxy addresses without affecting other existing values, use the following syntax.
Set-UnifiedGroup -Identity "Sales Group" -EmailAddresses @{Add="salesgroup1@domain.com",
"salesgroup2@domain.com"; Remove="salesgroup3@domain.com","salesgroup4@domain.com"}

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 salesgroupold@domain.com and the proxy address salesgroup3@domain.com, and adds the primary address salesgroupnew@domain.com and the proxy address salesgroup1@domain.com.
Set-UnifiedGroup -Identity "Sales Group" -EmailAddresses @{Remove="SMTP:salesgroupold@domain.com",
"smtp:salesgroup3@domain.com"; Add="SMTP:salesgroupnew@domain.com","smtp:salesgroup1@domain.com"; }

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

Advertisements
Advertisements

No comments:

Post a Comment