SharePoint Migration Tool (SPMT)

This tool allows you to migrate lists or files from your SharePoint on-premises document libraries or from your on-premises file shares and easily move them to either SharePoint or OneDrive in Office 365. It is available to Office 365 users.

In the latest version, Microsoft has introduced PowerShell cmdlets to perform migration that has all features of the SharePoint Migration Tool (SPMT).

Click here to download the SPMT latest version 2.1.100.0 (currently in open beta). The PowerShell .dll's will be copied to %userprofile%\Documents\WindowsPowerShell\Modules location.

Copy the below script and paste it in a Notepad. Save the file as SPMTMigration.ps1.

  1. # Module Location
  2. $Global:ModulePath = "C:\Users\vijai\Documents\WindowsPowerShell\Modules\Microsoft.SharePoint.MigrationTool.PowerShell"
  3. # File Share Source Location
  4. $Global:FileShareSource = "C:\Users\vijai\Desktop\DeploymentAutomation"
  5. # SharePoint Online Target Site Details
  6. $Global:SPOUrl = "https://c986.sharepoint.com/sites/dev"
  7. $Global:SPOCredential = Get-Credential
  8. $Global:ListName="Documents"
  9. # Import SPMT Module
  10. Import-Module ($modulePath + "\Microsoft.SharePoint.MigrationTool.PowerShell.psd1")
  11. # Create a migration session and initialize it
  12. Register-SPMTMigration -SPOCredential $Global:SPOCredential -Force
  13. # Add a new migration task to the registered migration session
  14. Add-SPMTTask -FileShareSource $Global:FileshareSource -TargetSiteUrl $Global:SPOUrl -TargetList $Global:ListName
  15. # Start the registered SPMT migration
  16. Start-SPMTMigration
  17. # Cancel the current migration session
  18. Stop-SPMTMigration
  19. # Remove the SPMT migration session created
  20. Unregister-SPMTMigration

Open PowerShell window and run the following command.

  1. >cd "<folderlocation>"

folderlocation – where the SPMTMigration.ps1 file is saved

Run the following command

  1. >.\SPMTMigration.ps1

Enter the SharePoint Online site credentials in the pop-up and enter OK. After a few minutes, the files from folder share will be migrated to SharePoint Online site.

Reference - https://docs.microsoft.com/en-us/powershell/module/spmt/?view=spmt-ps

Thus, in this blog, you saw how to migrate files from Folder Share to SharePoint Online using PowerShell based on the SharePoint Migration Tool (SPMT) migration engine.