Teams Admin: Creating Bulk Class Teams using PowerShell and a CSV file

Steel Contributor

For Your Information: I have successfully created Class Teams using PowerShell and a CSV file. This is very handy because you can have a whole list of teams, channels, teachers and students in a CSV file making creating a large number of teams a snap.

 

I have attached a PowerShell module and a sample CSV file. The method is similar to what is found here Create teams in Microsoft Teams through CSV using PowerShell | JiJi Technologies, though there are a few small differences. I did not write the script, I found it online - but I cannot remember where. I made a few minor changes where the original script gave errors. In the spirit of sharing, I have attached it here.

 

Basically you need to have PowerShell 5.1 and install the current MicrosoftTeams PowerShell module (in PowerShell) using the command Install-Module -Name MicrosoftTeams -RequiredVersion 1.1.6 (that being the current version as of this writing). You need to run PowerShell as administrator.

 

Prepare your CSV file using the example I have attached. Import the PowerShell module I have attached and run the function New-TeamsFromCSV.

 

Watch your computer do all the hard work while you relax!

 

4 Replies

Note: this format requires you to give the path to the CSV file when you run the function from the PowerShell command line. E.g.

New-TeamsFromCSV c:\powershell\NewTeams.csv #substitute with your path and filename.

 

@Marius Pretorius 

 

Hi,

thank you for your excellent script

 

Unforunatelly i am getting the following error 

Spoiler
New-Team : Error occurred while executing Code: BadRequest Message: Failed to execute Templates backend request CreateTeamFromTemplateRequest. Request Url: https://teams.microsoft.com/fabric/emea/templates/api/team, Request Method: POST, Response Status Code: BadRequest, Response Headers: Strict-Transport-Security: max-age=2592000 x-operationid: e33aa8f7bcaaf2409469a733f43c4d56 x-telemetryid: 00-e33aa8f7bcaaf2409469a733f43c4d56-2d04028de3c0164f-00 X-MSEdge-Ref: Ref A: 78BB7E144EAC4317B3AC67C206C16AB8 Ref B: LON21EDGE1113 Ref C: 2021-08-22T15:51:03Z Date: Sun, 22 Aug 2021 15:51:02 GMT , ErrorMessage : {"errors":[{"message":"Team Visibility must be one of known types: [Private,Public,HiddenMembership].","errorCode":"Unknown"}],"operationId":"e33aa8f7bcaaf2409469a733f43c4d56"} InnerError: RequestId: 415e5729-033a-4532-b76c-0524e12c9ddd DateTimeStamp: 2021-08-22T15:51:03 HttpStatusCode: BadRequest At C:\365\classes\CreateMsTeamsComprehensive.psm1:104 char:30 + ... $group = New-Team -MailNickName $team.TeamsName -displayname $tea ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SyntaxError: (Microsoft.Teams...Cmdlets.NewTeam:NewTeam) [New-Team], ApiException + FullyQualifiedErrorId : Team creation failed.,Microsoft.Teams.PowerShell.TeamsCmdlets.NewTeam

 

@Nikos_M  Did you find any solution to the issue? I ran into the same error-message.

Seems like we have to add a Team-Visibility Column to the CSV file.

Hi, I am not able to create teams bulk via above given commands , please see below error which I am getting

New-TeamsFromCSV -Path "C:\Users\username\bulkteamscreation.csv"
New-TeamsFromCSV : The term 'New-TeamsFromCSV' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ New-TeamsFromCSV -Path "C:\Users\username\bulkteamscreation.csv"
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (New-TeamsFromCSV:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException