Tip: Make Sure to Add Owners as Members When Creating New Teams

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:

Teams lists the membership of a team

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.

16 Replies to “Tip: Make Sure to Add Owners as Members When Creating New Teams”

    1. You could do this with PowerShell by running the Add-UnifiedGroupLinks cmdlet to add the admin account to each group.

  1. If you’ve already set the owner when you create the group, do you need to explicitly add them as a member as well? Also, when you add a user as a member and owner (using the Add-TeamUser cmdlet) does the order matter (i.e. member before owner?)

    1. 1. If you add an owner when you create a team, the owner is added as a group member as well.
      2. If you create a team with PowerShell and populate the membership after the team is created and use Add-TeamUser to add members, the cmdlet adds new owners both as a member and as an owner in the one command. For example, if you run Add-TeamUser -GroupId xxxx -User Jim.Smith@Office365itpros.com -role owner, Jim Smith is added as both an owner and a member. This is a change made a few months ago,.

  2. Hi Tony, if you have a number of groups with this issue because they were created before the POSH module was fixed, rather than remove all the owners and add them all back in again, is it feasible to fix them with Add-UnifiedGroupLinks -LinkType member. Or would that not do the job. Something like this.

    $grpname = “group_missing_owners_from_members”
    (Compare-Object (Get-UnifiedGroupLinks $grpname -LinkType owner) (Get-UnifiedGroupLinks $grpname -LinkType member) -Property name | ?{$_.SideIndicator -eq “<="} | select -ExpandProperty name) | %{write-host Adding Owner $_ as member to $grpname;Add-UnifiedGroupLinks -Identity $grpname -LinkType member -Links $_}

  3. Hi Tony,
    I need to add owners that are not members of the team (IT techs to manage membership).

    Set-UnifiedGroup -Identity $Line.NewGroup -UnifiedGroupWelcomeMessageEnabled:$false
    Add-TeamUser -GroupId $GroupID -User $TestUser -Role Owner
    Set-UnifiedGroup -Identity $Line.NewGroup -UnifiedGroupWelcomeMessageEnabled:$true
    Write-Host “Welcome message re-enabled. Timeout 20 sec before removing Owners as Members”
    Start-Sleep -s 20
    Remove-TeamUser -GroupId $GroupID -User $TestUser -Role Member

    However, when I run the following, they’re removed from both Owner & Member, although when I remove Owner role, member stays intact.
    Remove-TeamUser -GroupId $GroupID -User $TestUser -Role Owner

    1. Basically, a user can be an owner and a member of a group. However, to be an owner, they must first be a member. So when you remove the user as a member, you automatically remove them as an owner.

      1. In gui you can make them owners w/o members, so this is no longer true. Hence the question – how come I can do more in gui than in ps

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.