Migrate Microsoft Teams from one tenant to another manually

Migrate Microsoft Teams from one tenant to another manually

  •          Step #1: Re-create the teams you want to migrate at the destination
  •          Step #2: Add all of the correct users and permissions to each team

To invite bulk users to a Microsoft Teams team, you need to:

  • 1.     Extract users/permissions to a CSV file
  • 2.     Modify the domains associated with each user
  • 3.     Add users to the destination teams from the CSVfile
  • 4.     Modify permissions within each team

You need to have the SharePoint Online PnP PowerShell module installed in order to run this script.

function Export-TeamsList

{

param (

$ExportPath

)

process{

Connect-PnPOnline -Scopes "Group.Read.All","User.ReadBasic.All"

$accesstoken =Get-PnPAccessToken

$MTeams = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri "https://graph.microsoft.com/beta/groups?`$filter=resourceProvisioningOptions/any(c:c+eq+`'Team`')" -Method Get

$TeamsList = @()

$i=1 d

{

foreach($value in $MTeams.value)

{

Write-Progress -Activity "Get All Teams" -status "Found Team $i"

$id= $value.id Try

{

$team = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri https://graph.microsoft.com/beta/Groups/$id/channels -Method Get

}

Catch

{

}

$Owner = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri https://graph.microsoft.com/v1.0/Groups/$id/owners -Method Get

$Members = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri https://graph.microsoft.com/v1.0/Groups/$id/Members -Method Get

$Teams = "" | Select "TeamsName","TeamType","Channelcount","ChannelName","Owners","MembersCount","Members"

$Teams.TeamsName = $value.displayname

$Teams.TeamType = $value.visibility

$Teams.ChannelCount = $team.value.id.count

$Teams.ChannelName = $team.value.displayName -join ";"

$Teams.Owners = $Owner.value.userPrincipalName -join ";"

$Teams.MembersCount = $Members.value.userPrincipalName.count

$Teams.Members = $Members.value.userPrincipalName -join ";"

$TeamsList+= $Teams

$teamaccesstype=$null

$errorMessage =$null

$Teams=$null

$team =$null

$i++

}

if ($MTeams.'@odata.nextLink' -eq $null )

{

break

}

else

{

$MTeams = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri $MTeams.'@odata.nextLink' -Method

Get

}

}while($true);

$TeamsList.count

$TeamsList

$TeamsList | Export-csv $ExportPath-NoTypeInformation

}

}Export-TeamsList-ExportPath"C:\temp\teamswithmembers.csv"

The resulting CSV file includes the following information for each team:

Add users to the destination Teams from the CSV file

Install-Module -Name  PowerShellGet  -Force  -AllowClobber

Install-Module -Name  MicrosoftTeams -Force  -AllowClobber

Connect-MicrosoftTeams

Update-Module  MicrosoftTeams

Get-Team

Import-Csv -Path "C:\Users\NOMAN\Desktop\migration team.csv" | foreach{Add-TeamUser -GroupId "b5144937-93a8-45b5-b0d2-f760f2b2f373"-user $_.email}

Step #3: Download the contents of the associated SharePoint team sites and upload at the destination

Step #4: Export/import Teams chat history

Install-Module -Name ExchangeOnlineManagement

Import-Module ExchangeOnlineManagement; Get-Module ExchangeOnlineManagement

Update-Module  -Name ExchangeOnlineManagement

Connect-ExchangeOnline  -UserPrincipalName  admin@M365x196823.onmicrosoft.com

Get-mailbox -GroupMailbox | select  Displayname, WindowsEmailAddress

Get-mailbox  -groupmailbox  testmigration@M365x196823.onmicrosoft.com |  Get-MailboxFolderStatistics | select Foldertype,ItemsInFolder

Export each team’s TeamChat data

Navigate to the Content search page and create a Guided search.

  •          Choose the related Teams group as the location and add a condition of Type > Equals any of and select E-mail messages and Instant messages, then save and run your query.

  •          When your query has finished running, in the More drop-down menu click on Export report.

  •          Choose one of the All-items export options, then click on Download report
Once the report has been exported, open it in a compatible clientto view and save the team’s chat history. To make the conversation history viewable for team members, save it as a document and upload it to the “General” folder in the team’s associated SharePoint site (that way it will be visible in the team’s “File” tab in Microsoft Teams).

Repeat for every team you want to migrate.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us