SharePoint Migration Tool – Part 2

Migration with PowerShell


In the previous article I made a brief description of this Microsoft tool that can be used to migrate on-premises data to SharePoint Online. Since the last article, there have been a couple of updates. For example, migration from SharePoint Server 2010 is now also supported.

Before we begin

Before we can begin writing PowerShell code and migrating to SharePoint Online, it is first necesarry to install SPMT to the local computer. The tool can be downloaded from In case you want to use the public preview version however, you need to download it from

Migrating shared folder to SharePoint Online

In our example, we will use a shared folder and migrate it to a SharePoint Online page. To start the migration, let’s first take a look at the commands that are available in the PowerShell module. The easiest way to achieve this is if we use the command:

Get-Command -Module Microsoft.SharePoint.MigrationTool.PowerShell

The command returns the following commands:

  • Add-SPMTTask
  • Get-SPMTMigration
  • Register-SPMTMigration
  • Remove-SPMTTask
  • Show-SPMTMigration
  • Start-SPMTMigration
  • Stop-SPMTMigration
  • Unregister-SPMTMigration

Registering the migration

The first thing we need to do when performing a migration is to register. With the command Register-SPMTMigration we define the credentials we will use to connect to SharePoint Online. Additionally, we have many other parameters, such as:

  • MigrateFilesCreatedAfter and MigrateFilesModifiedAfter – we can use to define the filter for migration
  • SkipFilesWithExtensions – filter for file types
  • PreserveUserPermissionsForFileShare – copying rights of shared folders
  • UserMappingFile – file for mapping cloud and on premises files
Register-SPMTMigration -SPOCredential $cred -SkipFilesWithExtension "wmv","xsn" `
    -MigrateFilesAndFoldersWithInvalidChars:$true -AzureActiveDirectoryLookup:$true

Migration tasks

Before the start of the migration, we need to add tasks to the migration. We do this with the Add-SPMTTask command. We can add multiple tasks and use different sources. We can use a task where the source is a SharePoint site/list, but it is also possible to use a shared or local folder.

An example of a local folder migration:

Add-SPMTTask -FileShareSource C:\Share -TargetSiteUrl $destUrl -TargetList "SPMT Migration"

In the task we defined the following parameters:

  • FileShareSource – points to the local folder C:\Share
  • TargetSiteUrl – a variable with the URL to the SharePoint Online site
  • TargetList – name of the list/document library where the documents will be migrated to

One of the options we have when adding tasks to the migration is to use a JSON definition, which allows us to add multiple sources and destinations to a single task. The JSON must be constructed in the following manner:

          "TargetPath":"https://[SP Online Url]",
                   "SourceList":"Pomembni dokumenti",

And in the Add-SPMTTask, instead of defining the source and destination, we use the JSON definition:

Add-SPMTTask -JsonDefinition $myJsonDef 

When all our tasks are prepared, we can launch the migration with the following command:


If we add the ParametersValidationOnly parameter to Start-SPMTMigration, a validation of the data we entered will be performed instead of the migration itself. This can come in handy when we want to perform bigger migrations and we add many tasks. In our case we added only one task, so validating everything is really not that necessary.

When the migration is in progress, the PowerShell window (depending on the environment you are using – VS Code, ISE, PowerShell window) also shows a summary of the migration.

At the end of the migration, the tool tells us the location of the map, where we can find more detailed information about the migration. The tool prepares a report in CSV format and very detailed log files, where we can find all the information we need about the transfer of data to SharePoint Online.

SharePoint Migration Tool offers us quite a few options for migrating data to SharePoint Online. You can use a graphical interface or you can type scripts and migrate documents and data from lists using scripts. The examples shown in this series of articles were fairly simple and I hope they will be a good starting point for your migration.

If you have any additional questions, you can write me to

Robi Vončina

Author: Robi Vončina

Office Servers and Services MVP, MCT

Leave a Reply

Your email address will not be published. Required fields are marked *