/ Powershell

Updating the email address on an Office 365 group with Powershell

Earlier this week I showed how to get all the members from an Office 365 group. Today I'll show how to update attributes for a group. As of today this is the only way to update the email address for a group.

First of all we need to connect our Powershell session to Office 365 (or more specifically Exchange Online). See my previous post (Some neat Powershell-snippets for connecting to Office 365 and Exchange Online) on how to achieve that.

So after running: Connect-Online we can now access the online-cmdlets used for this post: Get-UnifiedGroup and Set-UnifiedGroup. Notice that we will use Get-UnifiedGroup instead of Get-MsolGroup this time.

Firstly to make sure we have the correct group we retrieve the group we want to change email address for:

Get-UnifiedGroup <TestGroup>

By using -Filters we could also for instance do a wildcard search

Get-UnifiedGroup -Filter {displayname -like  "Test*"}

#Or add even more criteria with operators
Get-UnifiedGroup -Filter {displayname -like  "Test*" -and name -like "test*"

Now, actually change the email address for the group:

Get-UnifiedGroup <groupname> | Set-UnifiedGroup -PrimarySmtpAddress "<test@domain>"

If we want we could also change some other settings for the group, such as hidden from address book, accept from external senders etc. Here is an example on how to make the group hidden: Set-UnifiedGroup Test -HiddenFromAddressListsEnabled


Andreas Selevik

Andreas Selevik

Solution Architect specialized in Windows & Azure Architecture, Office 365, PowerShell, Identity management and automation. Manchester United fanatic, father, husband and a very good winner...

Read More