One of the loudest complaints I hear from people when we talk about Groups is the lack of management features, so in this post in the Office 365 Groups for Admins series we will take a look at how you can manage your Unified Groups using PowerShell. In the previous post I actually already showed you how to use PowerShell to create Groups, but let’s take a step back.

Connecting PowerShell to Exchange Online

To start working with the Unified Groups in PowerShell we need to connect to Exchange Online and we do that by establishing a PowerShell session to a specific Uri, see code sample below, and then import that session to our local session. This means we do not have to install any PowerShell module or similar. This is how it should look like:

# We need some credentials of course
$UserCredential = Get-Credential

# Create the session
$Session = New-PSSession -ConfigurationName Microsoft.Exchange `
    -ConnectionUri https://outlook.office365.com/powershell-liveid/ `
    -Credential $UserCredential `
    -Authentication Basic -AllowRedirection

# Import the session
Import-PSSession $Session

# Do Stuff...

# Kill the session
Remove-PSSession $Session

There is nothing you need to modify here, just enter your credentials when asked for. Note that I close the remote session!

Unified Group cmdlets

There are a couple of Unified Group cmdlets available for us to use. Issuing

Get-Help UnifiedGroup

shows the following operations:

  • Add-UnifiedGroupLinks
  • Get-UnifiedGroup
  • Get-UnifiedGroupLinks
  • New-UnifiedGroup
  • Remove-UnifiedGroup
  • Remove-UnifiedGroupLinks
  • Set-UnifiedGroup

As you can see there are two types of cmdlets; one for creating, updating and removing Unified Groups and one listing, adding and removing “Group Links” (membership stuff), but more about those in the next post.

Get-UnifiedGroup

This cmdlet lists all you current Office 365 Groups. It’s perfect for creating reports. It has support for filtering options (very similar to Exchange mailbox management) or you can retrieve a specific group like this:

 Get-UnifiedGroup -Identity <groupalias>

Listing Groups

New-UnifiedGroup

We discussed this one in the latest post, so we keep this description short: this cmdlet creates new Groups.

Set-UnifiedGroup

This is most likely the most important cmdlet for managing Groups. It allows you to modify properties of the Groups.

Here are a couple of the operations you need to understand and use:

Hide a Group from the Address lists (GAL)

The request I hear the most often is  - I don’t want (certain) groups to be visible in the GAL. Then just use the HiddenFromAddressListsEnabled parameter and it will disappear from the address lists (a resync of the GAL is needed for client apps):

Set-UnifiedGroup -Identity <alias>  `
     -HiddenFromAddressListsEnabled $true

Changing the appearance

You can change the display name, primary and other e-mail addresses and even add Mail tips to a Group.

 Set-UnifiedGroup -Identity BossesGroup `
     -DisplayName "Contoso Bosses" `
     -MailTip "You're sending mail to a Group!!!!" `
     -PrimarySmtpAddress "bosses@contoso.com"

Group Mail Tips

Accept or Reject certain users from sending mails to groups

There might be situations when you do not want certain people to send messages to a group or you only want specific people to send messages. Then you can use the

RejectMessagesFromSendersOrMembers

or

AcceptMessagesOnlyFromSendersOrMembers

parameters. They work in a similar fashion as the similar parameters on the Set-DistributionGroup cmdlet. For instance this prohibits Garth Forth from sending messages to the Bosses Group.

Set-UnifiedGroup -Identity BossesGroup `
    -RejectMessagesFromSendersOrMembers garthf@contoso.com

Remove-UnifiedGroup

Pretty obvious what this one does - it removes a Group.

Summary

After reading this post you should find yourself comfortable starting managing Groups using PowerShell and even start writing your own reports (unless you can’t wait a couple of more days). In the next post I’ll continue with the Group Links and show you how to manage the membership of Groups.