Last active
April 25, 2021 00:26
-
-
Save patrick138/83ba1745cf162e5e75437ab844fb6783 to your computer and use it in GitHub Desktop.
Add users from text file or csv to a Microsoft Teams site
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adding multiple users to teams by PowerShell and a text / CSV file | |
1) Create a .txt file like this | |
Name | |
[email protected] | |
[email protected] | |
2) Install the Teams PowerShell tools: | |
Install-Module -Name MicrosoftTeams | |
-RequiredVersion 0.9.0 | |
3) Find the GroupId | |
PS get-team | |
4) Run this script | |
Import-Csv 'd:\email.txt' | % { | |
Add-TeamUser -User $_.Name -GroupId <GroupID> | |
} | |
It takes about 30 minutes or more before you see the updates users in Teams. Also an error will be displayed for all users that are alreay present. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$path='d:\email.txt' | |
$GroupId=<groupid> | |
Import-Csv $path | % { | |
Add-TeamUser -User $_.Name -GroupId $GroupId | |
} |
Hi.
Thanks for the solution - it works great, though it has one limitation that was not mentioned here :).
It works ONLY WITH MEMBERS - I cannot add guests to my team. Do you know of any possibility to bulk add (by importing a CSV for example) guest users to a team? (users with email addresses outside of the tenant). I can do this manually from the Teams interface but it takes forever if you have to do it with tens of users for multiple teams :(.
Here's another post I found which might be a solution if you edit the role column in CSV file:
https://flexmind.co/blog/how-to-add-bulk-users-from-csv-file-to-ms-teams-using-powershell/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Patrick - this is awesome. For extra credit, do you know how to:
Answers to either or both of those would greatly improve my happiness. :)