add-teamuser
1 TopicAdd ServiceAccount member to all teams via Powershell
I created a small powershell script to add my ServiceAccount user to all teams via "Add-TeamUser". Unfortunately I get this error message Add-TeamUser : Error occurred while executing Add-TeamUser Code: Authorization_RequestDenied Message: Insufficient privileges to complete the operation. InnerError: RequestId: 25ee1e0c-70cc-44bd-bfe9-b08d5bf05c36 DateTimeStamp: 2020-07-21T10:19:32 HttpStatusCode: Authorization_RequestDenied At C:\Users\XYZ\Documents\PSScripts\Others\AddTeamsMember.ps1:5 char:5 + Add-TeamUser -User ServiceAccount@evgiii.onmicrosoft.com -GroupId ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Add-TeamUser], ApiException + FullyQualifiedErrorId : Microsoft.TeamsCmdlets.PowerShell.Custom.ErrorHandling.ApiException,Microsoft.TeamsCmdlets.PowerShell.Custom.AddTeamUser My script looks like this: Connect-MicrosoftTeams $groups = Get-Team |Select GroupId, DisplayName foreach($group in $groups){ Add-TeamUser -User ServiceAccount@evgiii.onmicrosoft.com -GroupId $group.GroupId -Role Owner }2.1KViews0likes3Comments