Introduction

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

Note
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. }
  8. function CreateChannel {
  9. Param($credential, $team, [string] $DisplayName, [string] $Description)
  10. Connect - MicrosoftTeams - Credential $credential
  11. New - TeamChannel - GroupId $team.GroupId - DisplayName $DisplayName - Description $Description
  12. Disconnect - MicrosoftTeams
  13. }
  14. $credential = Get - Credential
  15. $DisplayName = Read - Host "Please enter Display Name of Teams"
  16. $Description = Read - Host "Please enter Description of Teams"
  17. $team = CreateTeam - DisplayName $DisplayName - Description $Description - credential $credential
  18. $DisplayNameChannel = Read - Host "Please enter Display Name of Channel"
  19. $DescriptionChannel = Read - Host "Please enter Description of Channel"
  20. CreateChannel - team $team - DisplayName $DisplayNameChannel - Description $DescriptionChannel - credential $credential

Conclusion

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.