Contents

Managing O365 groups with PowerShell

One of the much appreciated features in Office 365 are the new Office 365 Groups.

Group introduction

An Office 365 group provides a way to collaborate on a project with co-workers. When created, the Office 365 system creates a shared mailbox, shared calendar, a Sharepoint teamsite and a OneNote notebook for the team to use. When allowed by their tenant administrator, users can create a new Office 365 group themselves, without the need to contact their IT department.

When looking at these functionalities for our internal network, we decided they might come in handy for certain projects. To keep things as standard as possible, we needed a way to automate the creation of these groups as much as possible. And when you talk automation, you talk Powershell.

Automating group creation

It turns out you can manage new Office 365 groups through Powershell without hassle. In Powershell, these groups are referred to as unified groups. As you know, there are only three commands you know to learn Powershell: get-command, get-help and get-member. Let’s use these commands to check out what we can do with these groups in Powershell.

Ofcourse, we need to log on to our O365 tenant with Powershell first. After that, we’ll need to find out which commands are available.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Get-command *unifiedgroup*
CommandType Name Version Source
----------- ---- ------- ------
Function Add-UnifiedGroupLinks 1.0 tmp_2ha0g55b.ukr
Function Get-UnifiedGroup 1.0 tmp_2ha0g55b.ukr
Function Get-UnifiedGroupLinks 1.0 tmp_2ha0g55b.ukr
Function New-UnifiedGroup 1.0 tmp_2ha0g55b.ukr
Function Remove-UnifiedGroup 1.0 tmp_2ha0g55b.ukr
Function Remove-UnifiedGroupLinks 1.0 tmp_2ha0g55b.ukr
Function Set-UnifiedGroup 1.0 tmp_2ha0g55b.ukr

As you can see, there are multiple cmdlets to add, remove and manage new Office 365 groups. I would like to start out with creating a new group, so I’ll need some info on that.

1
2
3
get-help new-unifiedgroup
NAME New-UnifiedGroup
SYNOPSIS This cmdlet is available only in the cloud-based service.Use the New-UnifiedGroup cmdlet to create Office 365 groups in your cloud-based organization. To add members, owners, and subscribers to Office 365 groups, use the Add-UnifiedGroupLinks cmdlet.For information about the parameter sets in the Syntax section below, see Syntax.

To get some pointers on the use of this cmdlet, we can ask for some examples.

1
Get-help new-unifiedgroup -examples

So, let’s create a new group! Because I don’t want my colleagues to be able to see this group, I’ll set the accesstype to private.

1
New-unifiedgroup -DisplayName "Powershell Group" -alias powershellgroup -accesstype Private

Office 365 will no create the new group. It takes some time to complete the command, because the system will provision all parts of the group: a shared mailbox, shared calendar, OneNote notebook,

When the group is live, we can see what is stored about the group.

1
Get-unifiedgroup powershellgroup

After creating the group, we might want to add some members to it. The new-unifiedgrouplinks is what does just that.

Ofcourse, you can use the get-unifiedgrouplinks cmdlet to retrieve the members or owners of a group. A unifiedgrouplink can be of different types: owner, member or subscriber.

1
Get-unifiefdgrouplinks powershellgroup -linktype member
1
Add-unifiedgrouplinks -identity powershellgroup -linktype member -links ralph@meos.nl

By using this cmdlets, you could automate the creation, management and deletion of Office 365 groups. That way, you can set up all the groups you deploy in exactly the same way and perform these tasks automatically on certain triggers!