I have been working on a few OneDrive for Business migrations. The most recent one is a tenant-to-tenant migration. The client had bought Sharegate, so that is the tool we were going to use to do the migration.
One of the challenges with OneDrive for Business migrations is that each user’s OneDrive is its own site collection. That means each site source site has to be mapped to each destination site. Using the user interface is rather tedious and time consuming. Fortunately Sharegate has a PowerShell module attached to it that allows you to run a PowerShell script that references a .csv file with the mappings already paired up.
I was able to reference Sharegate’s Powershell documentation: https://support.share-gate.com/hc/en-us/categories/204661007-PowerShell to create the necessary script and .csv file to run a batch migration:
Step 1: Create a .csv file with the URL mappings.
Step 2: Write your tenant to tenant migration script.
#################
#CSV file with columns titled Name, SourceURL and DestinationURL:
$csvFile = "C:\OneDriveMigrations\TenantOneDriveMigration.csv"
#load the CSV file into a table
$table = Import-Csv $csvFile -Delimiter ","
#Convert your password to a SecureString
$mysrcpassword = ConvertTo-SecureString "********" -AsPlainText -Force
$mydstpassword = ConvertTo-SecureString "********" -AsPlainText -Force
$total++
#Cycle through each row
foreach ($row in $table)
{
#Set variables to blank incase a connection to one site fails, the site from the last loop isn't used.
$srcSite=''
$srcList=''
$dstSite=''
$dstList=''
$total++Write-Host “”
Write-Host “************************************************************”
Write-Host “”#connect to the destination OneDrive URL
$srcSite = Connect-Site -Url $row.SourceURL -UserName O365_Admin@source.onmicrosoft.com -Password $mysrcpassword
Write-Host “Connected to source site: ” $srcSite.Title#select destination document library, named Documents by default in OneDrive
$srcList = Get-List -Name Documents -Site $srcSite#connect to the destination OneDrive URL
$dstSite = Connect-Site -Url $row.DestinationURL -UserName O365_Admin@destination.onmicrosoft.com -Password $mydstpassword
Write-Host “Connected to destination site: ” $dstSite.Title#select destination document library, named Documents by default in OneDrive
$dstList = Get-List -Name Documents -Site $dstSite#Uncomment below code if running incremental migration
#$copysettings = New-CopySettings -OnContentItemExists IncrementalUpdate
Write-Host $total “- Attempting Migration: ” $row.Name#Copy the content from your source URL Documents in OneDrive to the Destination document library
if($srcSite -ne “” -and $dstSite -ne ”){
$result = Copy-Content -SourceList $srcList -DestinationList $dstList -InsaneMode # -copysettings $copysettings
Write-Host “Migration completed”#setName for logfile
$fileName = $row.Name#Export a report for each OneDrive migration
#Any folder specified in the path has to exist before running the script
Export-Report $result -Path C:\MyReports\$fileName
}
else {
Write-Host “Migration could not be completed”
$total–
$failed++
}
Write-Host “”
Write-Host “************************************************************”
Write-Host “”
}Write-Host $total “Migrations Attempeted”
Write-Host ($total-$failed) “Migrations Completed”
Write-Host $failed “Migrations Failed”################
Step 3: Open Sharegate and click on the PowerShell module:
Step 4: Run your script:
You should see something like this at the completion of the run:
Then you can review the reports and have the user’s verify their content has been moved.
Hope this helps!
Craig
2 Comments
Leave your reply.