Monday, September 25, 2023

Bulk add members in to MS Teams

 MS teams natively does not allow to bulk add members to new or existing teams. The process to add members one by one is pretty troublesome if you need to add 100+ members in one go. Powershell comes to you help in such a scenario.

First install the Microsoft Teams module in Powershell:

Install-Module -Name MicrosoftTeams

In case, its already installed but is of an older version, try to update it using:

Install-Module -Force -Name MicrosoftTeams

Once done, create a simple csv file with 2 columns : Email, Role and fill it up.

Next we need the group Id of the Team to which you want to add the members to. Yes there is powershell command for it as well but it was pretty slow specially when you member of 100's of Teams !!

Simple way was to pull it from the browser window. Just open Teams on the browser window and select the target Team, and look for the param groupId in the url:



Once done, just execute the below script:

#Get users from the CSV

$TeamUsers = Import-Csv -Path "<file_path>"

$TeamID = "<Team_Id / groupId>"

 

#Iterate through each user from the CSV and add to Teams

$TeamUsers | ForEach-Object {

       Add-TeamUser -GroupId $TeamID -User $_.Email -Role $_.Role

       Write-host "Added User:"$_.Email -f Green

}

You should see members getting added one by one: