Tutorial on how to do bulk invitation in Microsoft Teams

September 12, 2020  681 words 4 mins read  Join the Discussion

In my availability, I’m helping to manage an upcoming biological conference “Dynamics of biological systems: from viruses to populations” host by Garage of Complexity and lead by Dr. Marcin and his research group in Jagiellonian University. This conference will be organized online via Microsoft Teams due to COVID-19. Once the registration deadline is crossed, we planned to invite all the participants to our conference Team (aka group). But the tedious job I see is to invite people one by one. So, I asked myself a question. Can I do it all in bulk? Fortunately, I found a way to do this task in an easy way by using Microsoft Teams Powershell cmdlet. I’m very excited to share how I’m able to do this.

Let me share with you the very quick steps that you can follow. Please note that you will need a Windows operating system. If you know how to do the same thing in other operating systems then, please share it with me by commenting below.

First, you need to create a file named as say emailList.csv and add the email IDs like below. In my case, I already have this file downloaded from Indico’s conference website. But if you haven’t it then, the format should look like below.

email
[email protected]
[email protected]

Now, open the Windows Powershell as an administrator. You need to install the Microsoft Teams module in Powershell via PSGallery which is an official Microsoft repository. i.e.

Install-Module -Name MicrosoftTeams -RequiredVersion 1.1.4

Type A, which means “Yes to All” and hit Enter. Now the installation begins. Once the installation is finished, you need to connect to the Microsoft teams server by using this command:

Connect-MicrosoftTeams

Note: You can find the list of available commands in this link.

Now, the login page will pop-up in a new window and then, login with your Microsoft account which is associated with Teams.

The real thing begins from here: We need to add a list of people using their email address which will require the team’s group ID. This means which Team we need to add that list. I initially proceed by typing this command:

Get-Team

to extract the group ID. But unfortunately, it took me a lot of time to show all the available group IDs and I don’t like to wait. Help me out why it’s slow. So, I try to find a better way and I found it.

The idea to get the group ID of a specific team is by opening the Microsoft Teams app → Teams tab → Right click on Team to which you need to add members → Click “Get a link to Team” → Copy it → Paste it into the Notepad → In the link you will notice where is the groupId.

Then, you can use the below draft command to import all the people into your team:

Import-Csv -Path "emailList.csv_file_path" | foreach{Add-TeamUser -GroupId Paste_Group_ID -user $_.email}

What this above line basically does is that it passes the email ID on the “email” (called header in CSV language) column from the CSV file (using this | pipeline) to foreach loop placeholder $_.email. Let me give you an example to make you feel easy:

Import-Csv -Path "Desktop/emailList.csv" | foreach{Add-TeamUser -GroupId 789e1234-2b2a-4354-073f-02221410976s -user $_.email}

Don’t test this example it’s dummy :).

You can also use foreach alias % to shorten the line:

Import-Csv -Path "emailList.csv_file_path" | % {Add-TeamUser -GroupId Paste_Group_ID -user $_.email}

Suppose, you already have a CSV file say, which looks like this:

Name, Email Address, ...
test1, [email protected], ...
test2, [email protected], ...

Then, you can use the same way just by replacing the placeholder variable “email” by “Email Address”. i.e.

Import-Csv -Path "emailList.csv_file_path" | %{Add-TeamUser -GroupId Paste_Group_ID -user $_."Email Address"}

For example:

Import-Csv -Path "Desktop/emailList.csv" | %{Add-TeamUser -GroupId 789e1234-2b2a-4354-073f-02221410976s -user $_."Email Address"}

Finally, check your team, you will see everyone in the emailList.csv get invited. Hurray! You can now either close the Powershell Program directly or you can follow the below steps for your safety:

Disconnect-MicrosoftTeams

and hit Enter then, type

exit

Hit enter.

These steps nicely work in my case :).

Any feedback?

If you guys have some questions, comments, or suggestions then, please don't hesitate to shot me an email at [firstname][AT]physicslog.com or comment below.

Liked this post?

If you find this post helpful and want to show your appreciation, I would appreciate "a Coffee or Nepali Chi·ya (चिया)". It's a small gesture that can make my day!

Want to share this post?

  • Damodar Rajbhandari
    Written by Damodar Rajbhandari, a PhD candidate in the Mathematical Physics at the School of Mathematics & Statistics, University of Melbourne, Australia.