azurepowershellmicrosoft-graph-apioffice365microsoft-graph-teams

Error Cloning Microsoft Teams Group with PowerShell


I'm currently working with Microsoft support on a ticket related to updating the value of CreationOption for an M365 Group, as discussed in this post: M365 Group: update value of CreationOption. While awaiting a resolution, I attempted to clone the problematic Team group to a new Team-enabled M365 group.

However, I've encountered errors during the cloning process and am seeking insights or suggestions from the community. Specifically, I'm wondering if there are adjustments I can make to the scope permissions or other settings to troubleshoot the issue.

Below is the PowerShell script I've used for the cloning attempt, along with the error message received:

PowerShell

Install-Module Microsoft.Graph.Teams -Force
Import-Module Microsoft.Graph.Teams -MinimumVersion 2.15.0
Connect-MgGraph -Scopes Group.Read.All, Team.ReadBasic.All, TeamSettings.Read.All, TeamSettings.ReadWrite.All

# Get the Teams you have access to
##$teams = Get-MgTeam

# List all teams with their IDs
##$teams | Select-Object DisplayName, Id | Sort DisplayName

# Define parameters for the new team
$params = @{
    displayName = "Problem Team Copy"
    description = "Testing copy of Problem Team"
    mailNickname = "problemcopytest"
    partsToClone = "apps,tabs,settings,channels"
    visibility = "private"
}

$teamId = "8xxxxx88-xx8x-8xx8-8888-896x7x019xx4"

Copy-MgTeam -TeamId $teamId -BodyParameter $params

Error

Copy-MgTeam : Unable to fetch team thread: Failed to execute Skype backend request GetThreadRequest.
Status: 403 (Forbidden)
ErrorCode: Forbidden
Date: 2024-03-06T13:28:33
Headers:
Transfer-Encoding             : chunked
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : 8xx8xx8x-88xx-88x8-8x8x-514xx5x4x4x1
client-request-id             : 8x88xx88-88x8-88xx-8xxx-822x560x93x2
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"North Central US","Slice":"E","Ring":"3","ScaleUnit":"003","RoleInstance":"CH01EPF0002DB18"}}
Date                          : Wed, 06 Mar 2024 13:28:32 GMT
At line:15 char:1
+ Copy-MgTeam -TeamId $teamId -BodyParameter $params
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: ({ TeamId = 8xxx...ionJsonSchema }:<>f__AnonymousType3`3) [Copy-MgTeam_Clone], Exception
    + FullyQualifiedErrorId : Forbidden,Microsoft.Graph.PowerShell.Cmdlets.CopyMgTeam_Clone

Any advice or guidance on resolving this error and successfully cloning the Microsoft Teams group would be greatly appreciated.


Solution

  • When I executed the same script in my environment it worked successfully:

    Connect-MgGraph -Scopes Group.Read.All, Team.ReadBasic.All, TeamSettings.Read.All, TeamSettings.ReadWrite.All
    
    $params = @{
        displayName = "Problem Team Copy"
        description = "Testing copy of Problem Team"
        mailNickname = "problemcopytest"
        partsToClone = "apps,tabs,settings,channels"
        visibility = "public"
    }
    
    $teamId = "TeamID"
    
    Copy-MgTeam -TeamId $teamId -BodyParameter $params
    

    The team got cloned successfully like below:

    enter image description here

    With the same permissions as you, I am able to clone the team.

    If still the issue persists, check the below: