Forum Discussion
Set-Team Inconsistent Errors/Authorization
I am trying to write some powershell to manage Teams. I am using the latest 1.0.6 MicrosoftTeams module, updated just now to see if it would resolve my issue.
For example, if I run this and then run the second line over and over, it will succeed and randomly fail and then succeed again. It isn't this property in particular; I am working on a script with 8 different allow properties and each run a different one or two will fail but on the next run they work and other lines fail.
$groupid = (Get-Team -DisplayName 'CA-IT-Test').groupid
Set-Team -GroupID $groupid -AllowCreateUpdateRemoveTabs $false
Typical error message:
Set-Team : Error occurred while executing
Code: Unauthorized
Message: Unauthorized
InnerError:
RequestId: 73c502fd-9478-48fa-a0c9-2d08aca59e2e
DateTimeStamp: 2020-05-12T15:44:44
HttpStatusCode: Unauthorized
At line:1 char:1
+ Set-Team -GroupID $groupid -AllowCreateUpdateRemoveTabs $false
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-Team], ApiException
+ FullyQualifiedErrorId : Microsoft.TeamsCmdlets.PowerShell.Custom.ErrorHandling.ApiException,Microsoft.TeamsCmdlets.PowerShell.Custom.SetTeam