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:
- Using Graph API to create Automation for Teams
- Use Teams PowerShell
- 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.
- 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
- CreateTeam - For creating the team
- CreateChannel - For creating channel inside the team
- function CreateTeam {
- Param($credential, [string] $DisplayName, [string] $Description)
- Connect - MicrosoftTeams - Credential $credential
- $team = New - Team - DisplayName $DisplayName - Description $Description
- Disconnect - MicrosoftTeams
- return $team
- }
-
- function CreateChannel {
- Param($credential, $team, [string] $DisplayName, [string] $Description)
- Connect - MicrosoftTeams - Credential $credential
- New - TeamChannel - GroupId $team.GroupId - DisplayName $DisplayName - Description $Description
- Disconnect - MicrosoftTeams
- }
- $credential = Get - Credential
- $DisplayName = Read - Host "Please enter Display Name of Teams"
- $Description = Read - Host "Please enter Description of Teams"
- $team = CreateTeam - DisplayName $DisplayName - Description $Description - credential $credential
- $DisplayNameChannel = Read - Host "Please enter Display Name of Channel"
- $DescriptionChannel = Read - Host "Please enter Description of Channel"
- 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.