Migrate To SharePoint Online using SharePoint Online PowerShell – Updated!

Recently, I have had a few customers how to migrate file share content and/or SharePoint list/library data without the use of 3rd Party tools while retaining metadata.  There are a few blogs posts out there that are helpful but I thought I would add an updated post on the process.  Check out O365  SharePoint PowerShell!


Migrate File share data/SharePoint content to SharePoint Online while retaining metadata.


  • SharePoint content being migrated must be at least SharePoint 2010 version. (Source)
  • Office 365 Subscription (Destination)
  • Azure Subscription
  • Download & Install SharePoint Online Management Shell - https://www.microsoft.com/en-us/download/details.aspx?id=35588


  • Prep for migration - if migrating list/library content, you must setup list/library on destination site.
  • Package Content
  • Convert Packaged Content
  • Upload Package Content to Azure
  • Start Migration

Create Directories to Package Content

  • Create directories to handle packaging of content.  These will contain xml information about your content.
    • Temp Package > c:\migration\ContosoDocsPackageSource
    • Final Package > c:\migration\ContosoDocsPackageTarget

Create Destination List/Library

  • If migrating file share data, ensure you have a place to land content in SPO
  • If migrating SharePoint list/library content, ensure you have destination list/library with needed columns

Setup Migration

$cred = (Get-Credential admin@contoso.onmicrosoft.com)
$sourceFiles = 'C:\temp\migration\ContosoDocsPackage_Source' IF MIGRATING FILESHARE DATA, POINT TO FILES
$sourcePackage = 'C:\temp\migration\ContosoDocsPackage_Source'
$targetPackage = 'C:\temp\migration\ContosoDocsPackage_Target'
$targetWeb = 'https://Contoso.sharepoint.com/'
$targetDocLib = 'ContosoDocuments'
$adminSite = 'https://Contoso-admin.sharepoint.com'
$migrationMap = 'C:\temp\migration\contosoDocsUserMapping.csv' Optionally, map users when migration
$azureAccountName = 'YOUR ACCOUNT NAME'
$azureAccountKey = 'YOUR ACCOUNT KEY'
Connect-SPOService -Url $adminSite -Credential $cred

Create Migration Package

If migrating from File Share:

New-SPOMigrationPackage -SourceFilesPath $SourceFiles -OutputPackagePath $sourcePackage -TargetWebUrl $targetWeb -TargetDocumentLibraryPath $targetDocLib


If migrating from SharePoint List/Library content:

On your SharePoint server export your list or library

Export-SPWeb -Identity "http://sp2013/" -Path C:\temp\migration\contosoDocsExport -ItemUrl "/ContosoDocuments/" -NoFileCompression -IncludeUserSecurity -IncludeVersions All

Copy exported files from export above to machine where SPO Management Shell is install (where your creating migration packages) to the "Temp Package."

Convert Migration Package

If migrating from File Share:

New-SPOMigrationPackage -SourceFilesPath $SourceFiles -OutputPackagePath $sourcePackage -TargetWebUrl $targetWeb -TargetDocumentLibraryPath $targetDocLib

If migrating from SharePoint List/Library content:

$finalPackages = ConvertTo-SPOMigrationTargetedPackage -SourceFilesPath $sourceFiles -SourcePackagePath $sourcePackage -OutputPackagePath $targetPackage -Credentials $cred -TargetWebUrl $targetWeb -TargetDocumentLibraryPath $targetDocLib -NoAzureADLookup -Verbose -UserMappingFile $migrationMap -ParallelImport

Couple things to note: I'm using -NoAzureADLookup as I don't existing users in target domain and want to map them to new users. Map users by using -UserMappingFile and using -ParallelImport improves migration time when running multiple migrations.

Create CSV:

$csv = New-Item -Path C:\temp\migration -Name userMappingTest.csv -ItemType File -Value "OnPremSID,UPN,isGroup" -Force
Add-Content -Path $csv -Value "`nDomain\User,admin@contoso.onmicrosoft.com,FALSE"

Upload to Azure

$al = Set-SPOMigrationPackageAzureSource -SourceFilesPath $sourceFiles -SourcePackagePath $targetPackage -AzureQueueName $azureQueueName -AccountName $azureAccountName -AccountKey $azureAccountKey

Submit Migration Job

Submit-SPOMigrationJob -TargetWebUrl $targetWeb -MigrationPackageAzureLocations $al -Credentials $cred

Get Job Progress

Get-SPOMigrationJobProgress -TargetWebUrl $targetWeb -Credentials $cred


Use Windows PowerShell cmdlets for SharePoint Online and OneDrive Migration

SharePoint Online and OneDrive Migration User Guide

SharePoint Online limits and quotas

Microsoft Azure Storage Performance and Scalability Checklist

Upload on-premises content to SharePoint Online

Comments (0)

Skip to main content