In Blogs

Anyone who have ever done migrations know that they usually are not as easy initially thought. Using tooling most migrations can be made easier yet every tooling has their downsides or quirks. And in most cases the migration is mainly about communicating and reporting progress and info. So whatever tooling you are using make sure the process around what happens during the migration is clear for everyone involved.

Sharegate and PowerShell

Sharegate is a great tool to migrate your content and provides a set of PowerShell options to automate some of the steps. So in a recent project where we had to migrate a pretty decent set of content we resorted to Sharegate. Luckily Sharegate does support the use of PowerShell to start migrations.

In order to schedule and work with migrations during allowed time slots and delta’s we came up with a set of scripts that can process a CSV file and based on that input work with Sharegate. A great sample is provided by Sharegate themselves in Copy to and from multiple destinations with a CSV file. We used the same approach to migrate both thousands of users as well as thousands of sites.

Sharegate reports and PowerShell

To speed up the migration you can use the insane mode and have a fastest experience possible. However if you use this approach and try to export the reports you are confronted with the fact that it does not is the actual state. Sharegate reports back the results before the actual intake into Office 365 has been done. By running this way of importing for all OneDrives for instance you will have a bunch of reports that do not reflect the actual state (or errors).

$result = Import-Document -SourceFolder $row.NetworkPath -DestinationList $dstList -TemplateName "MyTemplate" -InsaneMode -CopySettings $coppySettings
$fileName = $rootDir + "\Processed\Migration_" + $row.Library + ".csv";
Export-Report -CopyResult $result -Path $fileName -Overwrite

The moment all data is uploaded to Azure (I guess) Sharegate reports back and thus the moment we export the report we get not all imported documents but only the uploaded stuff to Azure. In our case that resulted to two things; a set of csv (or xlsx) files that did not reflect the latest status as well as harder way to get the correct data. In our case we ended up with over 400 import sessions during a single day. Figuring out how many errors there where. Or figuring out what the status was during the intake in Office 365 was quite hard, and clicking through the UI isn’t optimal either.

Sharegate reporting

In order to overcome this challenge we wrote a few scripts to make live easier. The first one is a way to export all sessions that haven’t ended yet (thus being in progress). By using the the Find-CopySessions you can achieve this rather easily:

$allSessions = Find-CopySessions -From "2017/08/07 8:00:00" 
$unfinishedSessions = $allSessions | Where-Object { $_.HasEnded -eq $False }

This will return to you all sessions that are still in progress. By exporting those sessions to CSV and selecting the –NoItems and –NoItemVerion you will be presented with a CSV file with only the Azure Upload Jobs including a set of columns like the progress. You can than easily extend the script to read the CSV file. When reading that file you can extract the total items of processed by intake into Office 365 as well as the overall progress.

$unfinishedSessions | ForEach {
    $path = "C:\temp\"+$_.Id+".csv"
    $export = Export-Report -SessionId $_.Id -DefaultColumns -NoItems -NoItemVersion -Path $path -OverWrite 

    $report = Import-CSV $path -Delimiter ','

    $reportProgress = $report.'Office 365 Import: Progress %'
    $itemsProgress = $report.'Office 365 Import: # of objects processed'
    $itemsTotal = $report.'Office 365 Import: # of objects'

    Write-Host  $_.DestinationAddress"," reportProgress","$itemsProgress","$itemsTotal

As in the sample you can write out an overview of all unfinished sessions and get their progress of importing. This will help you to get an overview of the actual status of intake into Office 365 for you running imports. An ideal solution if you are importing hundreds of OneDrives simultaneously.

Originally posted at:

Neem contact op

Stuur ons een mail en we nemen zsm contact op.

Vul je zoekopdracht in.