For an Office 365 tenant to tenant migration, I wrote a small Powershell-script with the Sharegate API in order to fully migrate all necessary site collections from A to B.

The script will run on a VM, making it easy to keep migrating during and post business hours.

Be my guest to re-use the script and to make your migration run smoothly and without much manual interference. The script will traverse 3 steps:

  1. Create the site collection at the destination tenant
  2. Make your account a site collection administrator
  3. Migrate the site collection and its content

After every third site that is migrated, the script will prompt for manual continuation. You can easily remove this part or increase the number of sites migrated to your use case.

clear-host
Import-Module Sharegate

$arrayOfUrl = @([siteA],[siteB],[siteC])

$unameDest 	= [usernameDestination]
$pwdDest	= ConvertTo-SecureString [passwordDestination] -AsPlainText -Force
$unameSrc 	= [usernameSource]
$pwdSrc 	= ConvertTo-SecureString [passwordSource] -AsPlainText -Force
$tenantNameDestination = [tenantNameDestination]
$tenantNameSource = [tenantNameSource]

function Create-SiteCollection{
	param (
        [Parameter(Mandatory=$true,Position=1)]
		[string]$Username,
		[Parameter(Mandatory=$true,Position=2)]
		[string]$tenantName,
        [Parameter(Mandatory=$true,Position=3)]
		$password,
        [Parameter(Mandatory=$true,Position=4)]
		$arrayOfUrl
		)
		
	$userCredential = new-object -typename System.Management.Automation.PSCredential($username, $password)
	Connect-SPOService -Url "https://$tenantName-admin.sharepoint.com/" -Credential $userCredential

	foreach ($url in $arrayOfUrl) {
		try{
			$urlFull = "https://$tenantName.sharepoint.com/sites/" + $url
			Write-Host "Creating $url" -foregroundcolor White
			New-SPOSite -Url $urlFull -Template "STS#0" -Owner $username -StorageQuota "26214400" -TimeZoneId 3 -LocaleId 1043 -NoWait
		}
		catch{
			$ErrorMessage = $_.Exception.Message
			Write-Host $ErrorMessage -ForegroundColor Red
		}
	}
}

function Set-Admin{
	param (
        [Parameter(Mandatory=$true,Position=1)]
		[string]$Username,
		[Parameter(Mandatory=$true,Position=2)]
		[string]$tenantName,
        [Parameter(Mandatory=$true,Position=3)]
		$password,
		[Parameter(Mandatory=$true,Position=4)]
		[string]$adminAccount
		)
	
	$userCredential = new-object -typename System.Management.Automation.PSCredential($username, $password)
	Connect-SPOService -Url "https://$tenantName-admin.sharepoint.com" -Credential $userCredential

	$Sites = Get-SPOSite -Limit ALL
	 
	Foreach ($Site in $Sites)
	{
		Write-host "Adding Site Collection Admin for:"$Site.URL
		Set-SPOUser -site $Site -LoginName $adminAccount -IsSiteCollectionAdmin $True
	}
}

function Migrate{
	param (
        [Parameter(Mandatory=$true,Position=1)]
		[string]$unameSrc,
		[Parameter(Mandatory=$true,Position=2)]
		$pwdSrc,
		[Parameter(Mandatory=$true,Position=3)]
		[string]$unameDest,
		[Parameter(Mandatory=$true,Position=4)]
		$pwdDest,
		[Parameter(Mandatory=$true,Position=5)]
		[string]$urlSrc,
		[Parameter(Mandatory=$true,Position=6)]
		[string]$urlDest,
        [Parameter(Mandatory=$true,Position=7)]
		$arrayOfUrl
		)
		
	$i = 0;
	 
	foreach ($url in $arrayOfUrl) {
		if($i -gt 0 -and !($i % 3)){
			$cont = Read-host "Do you want to continue with the next 3 sites? (Y/N)" -foregroundcolor Yellow
			
			if($cont -eq "N"){
				break
			}
		}

		try{
			$urlSrc  = "https://" + $urlSrc + ".sharepoint.com/sites/" + $url
			$urlDest = "https://" + $urlDest+ ".sharepoint.com/sites/" + $url
			
			Write-host "Connecting to "$urlSrc -foregroundcolor Yellow
			$srcSite = Connect-Site -Url $urlSrc -Username $unameSrc -Password $pwdSrc
			
			Write-host "Connecting to "$urlDest -foregroundcolor Yellow		
			$dstSite = Connect-Site -Url $urlDest -Username $unameDest -Password $pwdDest
			
			Write-host "Migrating..." -foregroundcolor Yellow
			$copysettings = New-CopySettings -OnContentItemExists IncrementalUpdate
			$result = Copy-Site -Site $srcSite -DestinationSite $dstSite -Merge -Subsites -WaitForImportCompletion -CopySettings $copysettings
			
			$path = ".\Reports\" + $url + ".xlsx"
			Export-Report $result -Path $path
			Write-host "Report exported to "$path -foregroundcolor Yellow
			Write-host "--------------------------------------" -foregroundcolor Yellow
			$i++
		}
		catch{
			$ErrorMessage = $_.Exception.Message
			Write-Host $ErrorMessage -ForegroundColor Red
		}
	}
}

Create-SiteCollection -Username $unameDest -tenantName $tenantNameDestination -password $pwdDest -arrayOfUrl $arrayOfUrl

Set-Admin -Username $unameDest -Password $pwdDest -adminAccount $unameDest -tenantName $tenantNameDestination

Migrate -unameSrc $unameSrc -pwdSrc $pwdSrc -unameDest $unameDest -pwdDest $pwdDest -urlSrc $tenantNameSource -urlDest $tenantNameDestination -arrayOfUrl $arrayOfUrl

You could also schedule a task in Windows to run these kind of scripts overnight.