Create Teams In Bulk Using Teams PowerShell

In this article we will look at how multiple teams can be created from data present in a CSV file. We will be using Teams PowerShell to achieve this.
 

System Assumptions

 
This script will be executed in a Windows machine, with the Teams creation instructions being read from an CSV file. PowerShell ISE will be used to execute the commands and scripts.
 

Input File

 
This is the scenario. The CSV input file contains 15 teams with their details like – Team name, Team description, Visibility and owner of the team. We will use this data as the input for creating our teams via a PowerShell script.
 
 

Command for creating a team

 
The command for creating a team via PowerShell is shown below.
 
New-Team -DisplayName "My Dummy Team" -Description "This is a dummy team" -Owner "dev@collablogic.onmicrosoft.com" -Visibility Public
 
The above cmdlet creates a new team with parameters we specify and returns a Group object with a GroupID property. Along with this, an associated O365 Unified Group is also created to back the team.
 
To get more details about this command, run this below cmdlet to view the detailed help.
 
Get-Help New-Team
 
Script for bulk creation of teams
 
The script that will create the teams from input file is as follows,
  1. #Connnect to Microsoft Teams  
  2. $connection = Connect - MicrosoftTeams  
  3. try {  
  4.     #CSV File Path.Change this location accordingly  
  5.     $filePath = "C:\Users\Satya\Desktop\CreateBulkTeams.csv"  
  6.     #read the input file  
  7.     $loadFile = Import - Csv - Path $filePath  
  8.     foreach($row in $loadFile) {  
  9.         $teamName = $row.  
  10.         'Team name'  
  11.         $teamDescription = $row.  
  12.         'Team description'  
  13.         $teamOwner = $row.Owner  
  14.         $teamVisibility = $row.Visibility  
  15.         #create the team with specified parameters  
  16.         $groupID = New - Team - DisplayName $teamName - Owner $teamOwner - Description $teamDescription - Visibility $teamVisibility  
  17.         Write - Host "Team "  
  18.         $teamName " created successfully..."  
  19.     }  
  20.     Write - Host $loadFile.Count " teams were created" - ForegroundColor Green - BackgroundColor Black  
  21. catch {  
  22.     Write - Host "An error occurred:"  
  23.     Write - Host $_  
  24. }  
Illustration
 
The code is outlined as,
  • Establish a connection with the Teams tenant
  • Read the CSV file
  • Execute the Teams creation command within a foreach loop
It first establishes a connection via the Connect-MicrosoftTeams cmdlet.
 
 
Upon successful authentication, it moves to the next stage of reading data from the input csv. After the file load is successful, it then traverses through the foreach loop and creates the team with the specified parameters. The corresponding Office 365 groups providing the backbone to the Teams is also created.
 
 
Upon completion of the script, if we login to the Teams, we can see the new teams being added there.
 
 
The corresponding groups can also be seen from Admin Center (Microsoft 365 Admin Center --> Groups)
 
 
This explains a simple scenario of how Teams creation can be planned and provisioned to a large scale and organization wise. Manual tasks can be avoided while achieving some level of governance. The input file can be modified with multiple more parameters and make the Teams creation even more meaningful.
 
This marks the end of this article. In this article we saw how to create Teams in bulk via a simple powershell script.
 
This article can also be found in my personal blog collab logic. The PowerShell script can be found in my GitHub repo.