Error Message
Unable to access Team <TEAMNAME> SharePoint site. ---> The remote server returned an error: (403) Forbidden. ---> The remote server returned an error: (403) Forbidden
Resolution
Add the Administrator account to the teams as an owner. This can be done manually or using the PowerShell script below:
To add the admin as owner to all teams:
- Run Windows PowerShell as admin
- Install Teams PowerShell module if it is not already installed
- Execute command
Install-Module -Name MicrosoftTeams
- Execute command
- Run the following script (fill in the username and password):
Import-Module MicrosoftTeams
$username = ''
$password = ''
$secPass = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ($username,
$secPass)Connect-MicrosoftTeams -Credential $credential
$teamsToAddOwner = Get-Team | Where-Object { (Get-TeamUser -GroupId $_.GroupId
-Role Owner | Where-Object { $_.User -eq $username }) -eq $null }
$teamsToAddOwner | Add-TeamUser -User $username -Role Owner
After running the script, the user should be visible as an owner of the group from the Office Admin portal or the Azure portal. However, per Microsoft, these permission changes may take minutes or hours for the ownership to take effect in Teams. This script should be run at least 24 hours before the migration is attempted again.
If the user does not show as an owner after 24 hours, try one of the options below:
Manual options:
- Ask a current owner of the team to add the user as an owner from the Teams UI. This should take effect immediately.
- In the Office Admin portal or Azure portal, remove the user from the owner of the group and add it back again. This change may still require up to 24 hours to take effect.
PowerShell Option:
- The owner can be removed and re-added using the PowerShell script below:
$groupId = ''
$username = ''
Remove-TeamUser -GroupId $groupId -User $username -Role Owner
Add-TeamUser -GroupId $groupId -User $username -Role OwnerImportant
This remove and re-add can still require up to 24 hours to take effect.