Please forgive me, I’m posting about “Microsoft Teams Bulk Invitation”

Please forgive me, I’m posting about “Microsoft Teams Bulk Invitation”

In my available times, 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. But the tedious job we see is to invite people one by one. 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. But you need to forgive me for posting this non-physics post in this blog which I haven’t done before.

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 us by commenting below.

  • First, you need to create a file named as say “emailList.csv” and add the email IDs like below:
email
[email protected]
[email protected]
  • 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, by typing this:
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. 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 which 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 -> On 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}

Hehe! Don’t test this example it’s dummy 🙂 Now, you can skip green texts and read the next bullet point but it’s relevant to know anyway.

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”

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. I’m the proof 🙂

Feedback?

If you guys have some questions, comments, or insults then, please don’t hesitate to shot me an email or comment below.

Want to share this post?