How To Create Microsoft Teams And Channel Using PowerShell


Microsoft Teams has reached 115 million daily active users and this number is increasing day by day. Hence automating multiple processes of Microsoft Teams could be a requirement for many customers.
There are multiple options to provide this requirement: 
  1. Using Graph API to create Automation for Teams
  2. Use Teams PowerShell
  3. Use PnP PowerShell
There can be additional options as well so this could be a long list but in this blog we will cover how we can automate creating teams and channels using Teams PowerShell.

Using Teams PowerShell

Step 1 - Install Teams PowerShell
To install a Teams PowerShell Use the below command 

To check the latest version of Teams PowerShell check the link.
  1. Install-Module -Name MicrosoftTeams -AllowPrerelease -Scope CurrentUser   
Step 2 - PowerShell Script
To connect we would need to have tenant admin access or teams admin access.

In PowerShell script described below we have created two functions 
  1. CreateTeam - For creating the team
  2. CreateChannel - For creating channel inside the team
  1. function CreateTeam {  
  2.     Param($credential, [string] $DisplayName, [string] $Description)  
  3.     Connect - MicrosoftTeams - Credential $credential  
  4.     $team = New - Team - DisplayName $DisplayName - Description $Description  
  5.     Disconnect - MicrosoftTeams  
  6.     return $team  
  7. }  
  9. function CreateChannel {  
  10.     Param($credential, $team, [string] $DisplayName, [string] $Description)  
  11.     Connect - MicrosoftTeams - Credential $credential  
  12.     New - TeamChannel - GroupId $team.GroupId - DisplayName $DisplayName - Description $Description  
  13.     Disconnect - MicrosoftTeams  
  14. }  
  15. $credential = Get - Credential  
  16. $DisplayName = Read - Host "Please enter Display Name of Teams"  
  17. $Description = Read - Host "Please enter Description of Teams"  
  18. $team = CreateTeam - DisplayName $DisplayName - Description $Description - credential $credential  
  19. $DisplayNameChannel = Read - Host "Please enter Display Name of Channel"  
  20. $DescriptionChannel = Read - Host "Please enter Description of Channel"  
  21. CreateChannel - team $team - DisplayName $DisplayNameChannel - Description $DescriptionChannel - credential $credential  


Using PowerShell we can create automation for Teams and channel creation. We can even extend this by looping through excel with all the values already added or fetching the name and description from a SharePoint list.