Photo by Connor Danylenko from Pexels

Adding bulk users to Microsoft Teams private channels

Joaquin Guerrero
5 min readMay 25, 2020

--

So, you might have already created your Teams team and uploaded your members through PowerShell or Graph API, if you haven’t, be sure to check these other tutorials that might be useful.

For now, we don’t have an import feature or easy way to just copy and paste emails to add members into a private channel in a Microsoft Teams team, but we do have some options to undergo this process.

PowerShell to the rescue (Yes, Again)

If you have a Windows Machine or even a Linux, or Mac OS (Yes, PowerShell is now available for other OS too, be sure to check it here https://aka.ms/pscore6), you will be able to run some quick PowerShell scripts to bulk add members from a .csv file to a private channel.

Let’s get started, in this case I will be using a Windows 10 machine.

  1. In your search bar in Windows 10 or in your Start button, search for PowerShell. Select the Windows PowerShell app and the right click and Run as an administrator (We will need to install some modules so admin rights are needed for this).

2. Once PowerShell starts in admin mode, you should see a blue console popup, then type in the next command needed to install the Microsoft Teams PowerShell module that will let you run Teams specific commands. (If you have already uploaded your Teams Users using my past tutorial, you can skip this step as the module should be already installed)

Install-Module -Name MicrosoftTeams

3. Hit enter and the command will prompt for installation confirmation, type A and hit enter again.

4. If there weren’t any errors you should see the PowerShell command line ready for a next command.

5. Run the following command that will connect directly to Teams and let you run the commands we need to add users to our private channels.

Connect-MicrosoftTeams

It will prompt you with a login popup, here you will need to login with your institution credentials (email and password).

If you logged in correctly, you should see something like the following PowerShell screen

To simplify things, we are going to assume that your private channels have already been created from the web or desktop Teams client (Creating private channels from PowerShell is still in private preview).

If you haven’t created your private channels yet, you just need to go your Teams Client, go to the team in which you want your private channels created and click on the ellipsis ( … ) next to the Team name and click on Add Channel.

Then be sure to add your display name and check on the privacy to be Private.

6. Now with our existing Private Channels in our team we are ready to add the members from the .csv file. We will need our team ID, for this we will need to run a PowerShell command to list all of our teams. The command is the following:

Get-Team -user "YOUR USERNAME EMAIL"

You should see a list with all your teams and some other detail. Find the desired team and copy the GroupId.

7. Now you will need your .csv file with your user emails. For this you could use Excel or you could create a new Notepad file with the following format, just the email column and then one email per line.

Once you finish your email list, be sure to save the file as a .csv file.

8. Now that you have your .csv file with the emails, the PowerShell running in administrator mode, and the Teams module installed, it’s time to add our users to the desired channel.

For this you will need to run the following PowerShell command, that will go through each csv file email and add them into the Private Channel. (Be sure ti check that users already are members of that team, if not you might want to add them to the team first). Replace the YOUR_TEAM_ID in the next script with the Group ID you got in step 6, and replace YOUR_FILE_PATH with your file path. Replace YOUR_PRIVATE_CHANNEL_NAME with the name of your private channel.

Import-Csv -Path “YOUR_FILE_PATH” | foreach{Add-TeamChannelUser -GroupId YOUR_TEAM_ID -DisplayName "YOUR_PRIVATE_CHANNEL_NAME" -user $_.email}

If all the users are added correctly, you shouldn’t see any messages after the script ran.

And then you should see the users you just added reflected in the Team. Please note that it could take a while for users to be reflected in the channel, so if they aren’t appearing yet give it a while and refresh the admin panel for the channel.

PowerShell for Teams

As you just saw, there are plenty of Microsoft Teams commands that could be ran through PowerShell, helping you automate some simple tasks through scripting.

If you want to explore more of the PowerShell commands available you can check the documentation.

Be sure to check out my other tutorials around automation in Teams with Power Automate and PowerShell.

--

--

Joaquin Guerrero

Tech Geek | Travel Addict | Tico 🇨🇷 living @ CDMX 🇲🇽 | Sr. Program Manager for Microsoft Teams but these are my thoughts