Table of Contents
Creating New Teams is Easy
New teams can be created in a variety of ways – through a Teams client, via PowerShell, or by using the Graph API.
If you create a team via a client, the person creating the team is automatically added as the owner. Their account is also added to the membership of the underlying Azure Active Directory (and Office 365) group. Teams masks this fact by only ever displaying the owner entry if you check using a client or PowerShell.
For instance, here’s a small team with 1 owner and 3 members as viewed through the Teams client:
Examining Team Membership
If we look at the membership of the team via PowerShell, we see the following:
Get-TeamUser -GroupId eba86b74-aef7-4a6b-aa8a-b9769e97716e -Role member UserId User Name Role ------ ---- ---- ---- d36b323a-32c3-4ca5-a4a5-2f7b4fbef31c Kim.Akers@office365itpros.com Kim Akers member a3eeaea5-409f-4b89-b039-1bb68276e97d Ben.Owens@office365itpros.com Ben Owens (Business Director) member c6133be4-71d4-47c4-b109-e37c0c93f8d3 Oisin.Johnston@office365itpros.com Oisin Johnston member Get-TeamUser -GroupId eba86b74-aef7-4a6b-aa8a-b9769e97716e -Role owner UserId User Name Role ------ ---- ---- ---- eff4cd58-1bb8-4899-94de-795f656b4a18 Tony.Redmond@office365itpros.com Tony Redmond owner
But if we examine the membership via Azure Active Directory, we see:
Get-AzureADGroupMember -ObjectId eba86b74-aef7-4a6b-aa8a-b9769e97716e ObjectId DisplayName UserPrincipalName UserType -------- ----------- ----------------- -------- eff4cd58-1bb8-4899-94de-795f656b4a18 Tony Redmond Tony.Redmond@office365itpros.com Member d36b323a-32c3-4ca5-a4a5-2f7b4fbef31c Kim Akers Kim.Akers@office365itpros.com Member a3eeaea5-409f-4b89-b039-1bb68276e97d Ben Owens (Business Director) Ben.Owens@office365itpros.com Member c6133be4-71d4-47c4-b109-e37c0c93f8d3 Oisin Johnston Oisin.Johnston@office365itpros.com Member
And the same information is reported for the Office 365 Group:
Get-UnifiedGroupLinks -LinkType Member -id eba86b74-aef7-4a6b-aa8a-b9769e97716e Name RecipientType ---- ------------- TRedmond UserMailbox Kim Akers UserMailbox Ben Owens UserMailbox Oisin.Johnston UserMailbox
Planner Likes Members
Why is this important? Well, it’s not if you only ever create new teams via a client. It becomes important if you create new teams via PowerShell or the Graph, because it means that you should always add new owners as members first, and then add them as an owner. If you don’t, applications that check for membership of the underlying group will fail. Planner is one application that I know that won’t allow a team owner access unless they are also a member, but that doesn’t mean that there aren’t others that will also fail, now or in the future.
Creating a New Team with PowerShell
The right way to create a new team with PowerShell is to create the team with the New-Team cmdlet and specify the name of the team owner in the call (this also adds that person as a member). Afterwards, add other owners and members of the team with the Add-TeamUser cmdlet, making sure to add the owners first as a team member and then as an owner.
In this example, we create a new team and then add one owner and one member. The $TeamId variable stores the GUID for the new team, which makes it easy to call Add-TeamUser. As you can see, Donald Vickers is added both as an owner and as a member.
$TeamId = (New-Team -DisplayName "Planning Team" -Alias PlanningTeam -Description "Team for the folks who like to plan" -AccessType Private -Classification Confidential -Owner Brian.Weakliam@office365itpros.com) Add-TeamUser -GroupId $TeamId.GroupId -User Donald.Vickers@Office365itpros.com -Role Member Add-TeamUser -GroupId $TeamId.GroupId -User Donald.Vickers@Office365itpros.com -Role Owner
All good clean PowerShell fun…
Note: The current Teams PowerShell module is 0.9.6. You need to use this version to see things work as described in this article.
We cover using PowerShell to work with Teams and Office 365 Groups in Chapter 14 of the Office 365 for IT Pros eBook. We like Teams, so there’s lots to discuss.
