Microsoft Teams: How to Create Teams using PowerShell?

Requirement: Create a team in Microsoft Teams using PowerShell

How to Create a New Team using PowerShell?

Microsoft Teams is a powerful collaboration tool that can help your team work more effectively. You can use it to create chat channels, share files and documents, and collaborate on projects. But what if you need to create multiple teams? If you’re like me, you love automation. PowerShell is a great way to automate tasks, including the creation of new Microsoft Teams. In this blog post, I’m going to show you how to bulk create Microsoft Teams using PowerShell. Let’s get started!

Prerequisites: I assume you have Microsoft Teams Module installed already. If not, install it: How to Install PowerShell Module for Microsoft Teams?

To create a new team with PowerShell, use the cmdlet: New-Team

New-Team -DisplayName "Marketing Managers" -Visibility Private -Description "Teams for Marketing Managers" -MailNickName "MarketingMgr" -Owner "[email protected]"

This PowerShell creates a team. Please note, the New-Team cmdlet takes only two mandatory parameters, DisplayName and Visibility. You can add optional parameters such as description, owners, etc. to take control.

Bulk Create Microsoft Teams using PowerShell

Are you looking to bulk create Microsoft Teams? If so, PowerShell is the way to go! With the help of PowerShell and CSV, We can create multiple teams quickly and easily. Let’s walk through the steps needed to create multiple teams using PowerShell. We will also show you how to add members to each team.

Here is my CSV Template to create bulk teams:

The process to create multiple teams is simple: just download the CSV file, populate it with the desired team name, members, and other parameters and then run the script. You’ll be prompted to enter your credentials. Make sure you have a Microsoft Teams Admin role or higher.

#Parameters
$CSVFile = "C:\Temp\TeamCreationTemplate.csv"

Try {
    #Read the CSV File
    $TeamsData = Import-CSV -Path $CSVFile

    #Connect to Microsoft Teams
    Connect-MicrosoftTeams

    #Iterate through the CSV 
    ForEach($Team in $TeamsData)
    {
        Try {
            #Create a New Team
            Write-host -f Yellow "Creating Team:" $Team.TeamName
            $NewTeam = New-Team -DisplayName $Team.TeamName -Owner $Team.Owner -Description $Team.Description -Visibility $Team.Visibility -ErrorAction Stop
            Write-host "`tNew Team '$($Team.TeamName)' Created Successfully" -f Green

            #Add Members to the Team
            Write-Host "`tAdding Team members..." -f Yellow
            $Members = $Team.Members.Split(";")
            ForEach($Member in $Members)
            {
                Add-TeamUser -User $Member -GroupId $NewTeam.GroupID -Role Member
                Write-host "`t`tAdded Team Member:'$($Member)'" -f Green
            }
        }
        Catch {
            Write-host -f Red "Error Creating Team:" $_.Exception.Message
        }
    }
}
Catch {
    Write-host -f Red "Error:" $_.Exception.Message
}

Once the script execution is completed successfully, if you login to the Microsoft Teams, You should see all new teams added there. (If they are public, Or you are part of the private team, BTW!).

Create Teams in bulk from CSV using PowerShell

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply