With the WFH being the most used acronym on the Internet over the past few weeks, and challenges a lot of IT departments are facing, I thought it would be useful to explain for the Office 365 users amongst us how to enable Microsoft Teams for all your users and create those teams quickly whilst ensuring it’s done in a controlled manner.

Just to call it out here, but the scripts here aren’t my work, and I’ll link to where I found the golden nugget of information.

One of the biggest challenges of using the Office 365 stack I’ve found is that although their ‘admin’ GUI backend is improving, most of the options are only available using powershell modules, or GraphAPI. This is particularly difficult for IT folk who have spent their careers in Wintel and rely heavily on the GUI. Below is a fantastic powershell script I found at Jiji Technologies which I’ve updated and modified with recent updates to the Microsoft Teams powershell module.

Without teaching anyone how to suck eggs, all you’ve got to do is download the csv template, open it up in Excel and list each of the Teams you wish to create, whether they are public or private, who the owner is, and who the members are (via email address, separated by a semi-colon). Put the script and the .csv in a folder called MicrosoftTeams in the root of your C:\ drive, and run it from within the Powershell terminal.

I’ve provided the .ps1 and the blank .csv template at the end of this blog to get you started quickly.

function Create-Channel
{   
   param (   
             $ChannelName,$GroupId
         )   
    Process
    {
        try
            {
                $teamchannels = $ChannelName -split ";" 
                if($teamchannels)
                {
                    for($i =0; $i -le ($teamchannels.count - 1) ; $i++)
                    {
                        New-TeamChannel -GroupId $GroupId -DisplayName $teamchannels[$i]
                    }
                }
            }
        Catch
            {
            }
    }
}

function Add-Users
{   
    param(   
             $Users,$GroupId,$CurrentUsername,$Role
          )   
    Process
    {
        
        try{
                $teamusers = $Users -split ";" 
                if($teamusers)
                {
                    for($j =0; $j -le ($teamusers.count - 1) ; $j++)
                    {
                        if($teamusers[$j] -ne $CurrentUsername)
                        {
                            Add-TeamUser -GroupId $GroupId -User $teamusers[$j] -Role $Role
                        }
                    }
                }
            }
        Catch
            {
            }
        }
}

function Create-NewTeam
{   
   param (   
             $ImportPath
         )   
  Process
    {
        Import-Module MicrosoftTeams
        $cred = Get-Credential
        $username = $cred.UserName
        Connect-MicrosoftTeams -Credential $cred
        $teams = Import-Csv -Path $ImportPath
        foreach($team in $teams)
        {
            $getteam= get-team |where-object { $_.displayname -eq $team.TeamsName}
            If($getteam -eq $null)
            {
                Write-Host "Start creating the team: " $team.TeamsName
$group = New-Team -MailNickName $team.TeamsName -displayname $team.TeamsName -Visibility $team.TeamType
                Write-Host "Creating channels..."
                Create-Channel -ChannelName $team.ChannelName -GroupId $group.GroupId
                Write-Host "Adding team members..."
                Add-Users -Users $team.Members -GroupId $group.GroupId -CurrentUsername $username  -Role Member 
                Write-Host "Adding team owners..."
                Add-Users -Users $team.Owners -GroupId $group.GroupId -CurrentUsername $username  -Role Owner
                Write-Host "Completed creating the team: " $team.TeamsName
                $team=$null
            }
         }
    }
}

Create-NewTeam -ImportPath "C:\MicrosoftTeams\NewTeams.csv"

I know this is probably a bit late, but if it helps someone out, then its worth sharing!