-
-
Save patrick138/83ba1745cf162e5e75437ab844fb6783 to your computer and use it in GitHub Desktop.
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. |
$path='d:\email.txt' | |
$GroupId=<groupid> | |
Import-Csv $path | % { | |
Add-TeamUser -User $_.Name -GroupId $GroupId | |
} |
These are the user email in my email.txt file
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
This is my script. In group i will add my team group id
$path='C:\Users\suma\Downloads\package\email.txt'
$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 :(.
Hey Patrick - this is awesome. For extra credit, do you know how to:
- tag users as they are added; and
- Prevent MS Teams from sending an email?
Answers to either or both of those would greatly improve my happiness. :)
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/
Hi Patrick,
I tried your script, but I have an error at $_.Name.
According to my template, I have my user's name format as [email protected]
I am getting an error at that name field. Can you please help me.