Create Microsoft Team with PowerShell and MS Graph API

The next Post in my GRAPH API Series now switches to Microsoft Teams and a heavily used Task. Create a Microsoft Team with PowerShell and Microsoft Graph API.

To learn more from Microsoft GRAPH API, see my Blog Series:
Part 1 – Authentication and Azure App – Use Microsoft Graph API with PowerShell – Part 1 » TechGuy
Part 2 – Oauth2.0 – Use Microsoft Graph API with PowerShell – Part 2 » TechGuy
Part 3 – First Powershell Script to get a Teams Lis and Walkthrough – Use Microsoft Graph API with PowerShell – Part 3 » TechGuy
Part 4 – this one – Use Microsoft Graph API with PowerShell – Part 4 » TechGuy

API Reference and Permissions

We used the following Docs to get this Script up and running

and I configured the following Permissions

  • User.Read.All
  • User.ReadWrite.All
  • Directory.Read.All
  • Directory.ReadWrite.All
  • Team.Create
  • Teamwork.Migrate.All
  • Group.ReadWrite.All
  • Directory.ReadWrite.All

The Script

$clientID = "your ID"
$Clientsecret = "your Secret"
$tenantID = "Your Tenant"

$TeamName="Techguy Team"
$TeamDescription="The official Team for"
$TeamVisibility="public" #public, private

#Connect to GRAPH API
$tokenBody = @{
    Grant_Type    = "client_credentials"
    Scope         = ""
    Client_Id     = $clientId
    Client_Secret = $clientSecret
$tokenResponse = Invoke-RestMethod -Uri "$tenantID/oauth2/v2.0/token" -Method POST -Body $tokenBody
$headers = @{
    "Authorization" = "Bearer $($tokenResponse.access_token)"
    "Content-type"  = "application/json"

#Get Owner ID

$URLOwnwer = "$Owner"
$ResultOwner = Invoke-RestMethod -Headers $headers -Uri $URLOwnwer -Method Get

#Create Teams
$BodyJsonTeam = @"
            $URLTeam = ""

            Invoke-RestMethod -Headers $headers -Uri $URLTeam -Method POST -Body $BodyJsonTeam 

GitHub Repo

Here you can find the GitHub Repo with a lot of other examples: Seidlm/Microsoft-Graph-API-Examples (

Deleagte New Teams creation as Self Service with au2mator

With au2mator Self Service Portal, you can create a Service and delegate the Task to create a new Microsoft Teams Team.

Some of the Use cases❗
✔️Make sure not everyone can create new Teams
✔️Do not have multiple Teams for the same Topic
✔️Control the naming convention of new Teams
✔️Many more…

More Details:

Michael Seidl aka Techguy
au2mate everything

Leave a Comment

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