How to add one user to bulk microsoft teams

HASSAN BIN NASIR DAR 396 Reputation points
2023-02-20T02:02:10.3266667+00:00

Hi

I have a questions regarding Microsoft Teams.Please answer me. thanks

I have 200 microsoft Teams in my tenant. I want to add one user "jhon" (as a admin) in 50 specifically microsoft teams. I have a csv file of 50 teams. How can I add "Jhon" as a admin in 50 microsoft teams.? And after that how can I remove this user to all these 50 microsoft teams.

Please suggest me powershell cmdlt.

Regards

Microsoft Teams | Development
Microsoft Teams | Development

Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs

Microsoft Teams | Microsoft Teams for business | Other

Answer accepted by question author
SokiGuo-MSFT 31,836 Reputation points Microsoft External Staff
2023-02-20T09:12:28.0233333+00:00

Hi @Anonymous

Teams tag is mainly focused on the general issue of Microsoft Teams troubleshooting, script is not in our scope. The following recommendations are for informational purposes only:

How can I add "Jhon" as a admin in 50 microsoft teams.?

  1. Create a UserInfo.csv file which contains GroupID, UserID and Role as below. Save this file in c:\Temp\UserInfo.csv.
    129776-image.png
  2. Connect to Microsoft Teams module: $User = admin@xxxxxxxxxxxxx .onmicrosoft.com
    $PassWord = ConvertTo-SecureString -String "YourPassword" -AsPlainText -Force $UserCredential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User, $PassWord import-module microsoftteams
    Connect-MicrosoftTeams -Credential $UserCredential -AccountId $User
  3. Add user as owner in bulk: $users = import-csv c:\Temp\UserInfo.csv
    Foreach($user in $users)
    {
    Add-TeamUser -GroupId $user.GroupID -User $user.UserID -Role $user.Role
    }

And after that how can I remove this user to all these 50 microsoft teams.

Remove the role owner but stays as a team member: $users = import-csv c:\Temp\OwnerInfo.csv
Foreach($user in $users)
{
Remove-TeamUser -GroupId $user.GroupID -User $user.UserID -Role Owner
}


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.