Question1. How to add owners in teams for bulk teams via PowerShell
You can use Add-TeamUser cmdlet to realize your requirement.
I create a demo as below for reference:
- Create a UserInfo.csv file which contains GroupID, UserID and Role as below. Save this file in c:\Temp\UserInfo.csv.
- 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 - 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
}
Question 2. is there any PowerShell script or any option as we have many teams where we need to change owners and make them as member of those teams?
The process is similar with adding owners in teams:
- Create a OwnerInfo.csv file which contains GroupID, UserID. Save this file in c:\Temp\OwnerInfo.csv.
- Connect to Microsoft Teams module( refer to the step 2 in your first question)
- 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
}
As we are mainly responsible for general question of Microsoft Teams, script is not in our scope. So, I will add office-teams-app-dev tag for further help if possible.
If the response is helpful, please click "Accept Answer" and upvote it.
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.