Office 365 Groups for Admins - managing Group memberships with PowerShell

Tags: Office 365, Unified Groups, PowerShell

In the last post of the Office 365 Groups for Admins series I showed you how to manage the Unified Groups using PowerShell. Let's continue on that journey and take a look at how you can manage the Group memberships using PowerShell.

All membership management are done using the *-UnifiedGroupLinks cmdlets, you can access them using PowerShell and connecting to Exchange Online as shown in the previous post. The cmdlets is at the moment that well documented. If that changes I'll make sure to update this post (and please remind me).

Public vs Private Groups

Before we dive into Memberships let's take a look at Public vs Private Groups, something you configure when creating the Group. In Public Groups anyone within your Organization can participate in discussions and access its content, whereas in Private Groups you have to be a member.

Listing members of Groups

First of all assume that we want to list the members of a Group. There are three types of Memberships in Office 365 Groups:

  • Members
  • Owners
  • Subscribers

To show all the Members of a Group issue the following command:

Get-UnifiedGroupLinks -Identity "XT1000 Marketing" -LinkType "Members"

The LinkType parameter can be either Members, Owners or Subscribers.

Adding members to a Group

To add one or more accounts as a Member to a Group you use the Add-UnifiedGroupLinks cmdlet as follows:

Add-UnifiedGroupLinks `
    -Identity "XT1000 Marketing" `
    -LinkType "Members" `
    -Links @("garthf@contoso.com","robinc@contoso.com")

Identity is the Group, LinkType has to be either Members, Owners or Subscribers and Links should be a single or an array of mailboxes.

To add a new admin to the Group, you use the LinkType set to Owners. But, before issuing that command you need to make the user a Member of the Group, so it is a two-stage rocket like this to make someone an admin:

Add-UnifiedGroupLinks `
    -Identity "XT1000 Marketing" `
    -LinkType "Members" `
    -Links "garthf@contoso.com"
Add-UnifiedGroupLinks `
    -Identity "XT1000 Marketing" `
    -LinkType "Owners" `
    -Links "garthf@contoso.com"

Subscribers are basically just members but they have decided to Subscribe to events from the Group. They are added just like Owners - first a Member Group Link and then a Subscriber Group Link.

Note that the user creating the Group, using PowerShell, will always be an Owner (and Member).

Removing members from Groups

Removing users from a Group are very similar to adding them. If they are Owners or Subscribers that Group Link has to be removed first, then the Member Group Link:

Remove-UnifiedGroupLinks `
    -Identity "XT1000 Marketing" `
    -LinkType "Owners" `
    -Links @("garthf@contoso.com") `
    -Confirm:$false
Remove-UnifiedGroupLinks `
    -Identity "XT1000 Marketing" `
    -LinkType "Members" `
    -Links @("garthf@contoso.com") `
    -Confirm:$false

Summary

This post showed with a few examples on how to manage memberships in Office 365 Groups, using PowerShell and the *-UnifiedGroupLinks cmdlets. In the upcoming posts we'll take a look at how to combine the different cmdlets to produce some good reports of the Unified Groups.

1 Comment

  • Alana said

    Mr. Wilen, I am trying to create a list of all of the owners of every group that has been created and their email address. I am having trouble coming up with the powershell script needed to do this. Can you help?

Comments have been disabled for this content.

About Wictor...

Wictor Wilén is the Nordic Digital Workplace Lead working at Avanade. Wictor has achieved the Microsoft Certified Architect (MCA) - SharePoint 2010, Microsoft Certified Solutions Master (MCSM) - SharePoint  and Microsoft Certified Master (MCM) - SharePoint 2010 certifications. He has also been awarded Microsoft Most Valuable Professional (MVP) for seven consecutive years.

And a word from our sponsors...