How to create a team with PnP PowerShell

Sometimes I like a nice challenge. I came across a Tweet from Joanne Klein with a question about Microsoft Teams provisioning. This article describes how to create a team with PnP PowerShell and the Microsoft Graph.

Update 24/03: I have created a new blog which uses the Create Team method.

The question from Joanne

On the 23rd of january I spotted this Tweet and the first response from Drew Madelung pointed me in the right direction for a solution.

My first attempt to create a solution

The following script is the end result of my attempt to recreate the solution suggested by Drew Madelung. I choose to use Microsoft Graph and PnP PowerShell.

Feel free to use it (of course at your own risk ;)).

Breakdown of the solution

Basicly the script has three parts. First of all you need to connect with the Microsoft Graph and get an access token. I am using the latest PnP PowerShell module for this, so make sure you download this module before running the script.

After that you can use a POST request to create an Office 365 Group via the Microsoft Graph. This is the first step in the creation of a Team.

In the second step I am using the Group ID of the reponse to use a PUT request to create a Microsoft Team.

You may also like...

3 Responses

  1. Paul H says:

    Hi Dennis, great post but unfortunately i’m getting stuck with an “Access token is empty” error when i run the script. the token isn’t empty if i view the variable. Any ideas? Thanks PH

  2. Dennis says:

    @Paul H, have you tried just connecting and getting the access token? Does that actually work?

    So try to run only these two lines:
    Connect-PnPOnline -Scopes “Group.ReadWrite.All”
    $accesstoken = Get-PnPAccessToken

    Btw, which version of PnP PowerShell module are you using?

  1. March 24, 2019

    […] Create Team. With this method you are able to create teams with just one request. So compared to my previous post this is easier when you want to create a team from […]

Leave a Reply

Your email address will not be published. Required fields are marked *

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