Migrate to SharePoint Online Using PowerShell

Aftab Alam
Aftab Alam linkedin | Updated On - November 23, 2022 |

Read time: 4 minutes

SharePoint Online is a cloud-based platform that helps in collaboration in organizations. It allows employees in different geographical locations to work together. Now the user can access the data in sites, lists/libraries, documents using any device connected to the Internet. Here are the main advantages of SharePoint Online.

  • Universally available You can access the data of the SharePoint Online using any PC, smartphone, or tablet from anywhere.
  • Share and collaborate You can allow other users to share your site by inviting them to your site. You only need to provide them the permission to access the site, and they can view or modify the data there.
  • Web Analytics SharePoint Online consists of some useful pre-built Web Analytics feature which checks the data usage and presents various reports.
  • Easy management of permissions The permissions in the SharePoint are easily manageable, flexible, and configurable. There are Permissions inheritance, SharePoint roles, etc. which work together to control user access to the SharePoint data.

Migrate to SharePoint Online Using PowerShell

The process of migrating data from an on-premises platform to SharePoint Online is not an easy one, and you need proper planning and in-depth information about both platforms. However, Microsoft has designed a tool (SPMT), which can access site data, lists/libraries from the on-premises SharePoint, and move to SharePoint Online easily.

The tool can run the migration job for the individual site as well as the large enterprise level data. It allows you to migrate the on-premises data to Office 365 and collaborate with the users more flexibly. The tool can migrate the data from the following SharePoint versions –

  • SharePoint Server 2019, 2016, & 2013.
  • SharePoint Foundation 2013, & 2010.
  • SharePoint Server 2010.
  • Network and other local shared files.

The tool is present at the following URL –

You can install the tool and run the migration.

Read Also: Quick Checklist for SharePoint Migration

Alternately, you can use PowerShell cmdlets for creating a migration task and run it. Here is the process:

  1. Create a migration session
    Define the SharePoint source

    $$Global:SourceSiteUrl = “on-premises site name”
    $Global:OnPremUserName = “<your login name>”
    $Global:OnPremPassword = ConvertTo-SecureString -String “<on-premieses password>” -AsPlainText -Force
    $Global:SPCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Global:OnPremUserName, $Global:OnPremPassword
    $Global:SourceListName = “<Source List Name>”

    Define the SharePoint Online target

    $Global:SPOUrl = “<SP Online url>”
    $Global:UserName = “<SP Online admin user name>”
    $Global:PassWord = ConvertTo-SecureString -String “<SP Online Password>” -AsPlainText -Force
    $Global:SPOCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Global:UserName, $Global:PassWord

    Import the SPMT Migration Module:

    Import-Module Microsoft.SharePoint.MigrationTool.PowerShell

    The cmdlet will register the SPMT session with the SPO credential:

    Register-SPMTMigration -SPOCredential $Global:SPOCredential -Force
  2. Add a migration task with the newly registered migration session
    Add-SPMTTask -SharePointSourceCredential $Global:SPCredential -SharePointSourceSiteUrl $Global:SourceSiteUrl -TargetSiteUrl $Global:SPOUrl -MigrateAll

    The cmdlet will create migration task for the SharePoint.

  3. Start the migration task
    Run the cmdlet Start-SPMTMigration to initiate the migration task.
  4. Get the status of the migration
    Run this cmdlet to get the status of the migration.

    $session = Get-SPMTMigration

    It will show the count of scanned files, migrated files, and any potential error message.
    If you started the migration using the -NoShow parameter, then you can use the Show-SMTPMigration to get the migration status.
    Just run the command Show-SPMTMigration, and it will bring the migration status, task ID, source location, and target location.

  5. Stop migration
    After the completion of migration, you need to stop the ongoing batch.


    The command will stop the batch immediately.

  6. Unregister the session
    When you have completed the migration of a single batch, you can either choose to run another batch or unregister the session to disable to connection with SharePoint Online.


    The command removes the SPMT session.


PowerShell commands will help you migrate to SharePoint Online. But while running the migration, there are chances that due to a wrong command or complexity of the method, the command does not work. For a secure and error-free migration, always use Kernel Migrator for SharePoint. This SharePoint Migration tool ensures the integrity of data and provides in-depth features and services for a thorough migration.

Kernel Migrator for SharePoint