I am using sharepoint.migrationtool. How do I automate the migration?

OL 0 Reputation points
2025-08-12T22:12:25.07+00:00

Hi,

I have folders in Share Point from local files, I want to migrate to local files to update SharePoint

I use microsoft.sharepoint.migrationtool.advancedapp.exe to migrate

But I want to automate the process

I tried to run a JSON file like this:

{

"Tasks": [

{

"SourcePath": "Local file path",

"TargetPath": "SharePoint path",

"TargetList": "Documents",

"TargetListRelativePath": "Folder name",

"Settings": {

"DefaultPackageFileCount": 0,

"MigrateSiteSettings": 0,

"MigrateRootFolder": true

},

"MigrationType": "Content"

}

]

}

With the correct data of course

I ran it in POWER SHELL like this:

C:...\Apps\SharePointMigrationTool\SPMT\microsoft.sharepoint.migrationtool.advancedapp.exe -task jsonFilePath.json

Result: The EXE loaded and a white screen appeared - probably connecting to Microsoft - which is not possible in an automated process.

Is there a way to automate the migration process?

Thanks!

Microsoft 365 and Office | SharePoint | Development
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Teddie-D 3,290 Reputation points Microsoft External Staff Moderator
    2025-08-13T05:15:13.86+00:00

    Hi @OL 
    Thank you for posting your question in the Microsoft Q&A forum. 

    As moderators, we have certain limitations within our test environment, which unfortunately prevent us from fully reproducing the issue you've encountered. After thorough research, I found this helpful article Start-SPMTMigration (Microsoft.SharePoint.MigrationTool.PowerShell) | Microsoft Learn which may meet your requirement. 

    You may take this PowerShell script from Microsoft as a reference for automating SharePoint migration using the SharePoint Migration Tool.  

    # Define SharePoint 2013 data source  
    $SourceSiteUrl = "https://YourOnPremSite/" 
    $OnPremUserName = "Yourcomputer\administrator" 
    $OnPremPassword = ConvertTo-SecureString -String "OnPremPassword" -AsPlainText -Force 
    $SPCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $OnPremUserName, $OnPremPassword 
    $SourceListName = "SourceListName" 
      
    # Define SPO target 
    $SPOUrl = "https://contoso.sharepoint.com/" 
    $UserName = "******@contoso.onmicrosoft.com" 
    $PassWord = ConvertTo-SecureString -String "YourSPOPassword" -AsPlainText -Force 
    $SPOCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $UserName, $PassWord 
    $TargetListName = "TargetListName" 
      
    # Define File Share data source 
    $FileshareSource = "YourFileShareDataSource" 
      
    # Import SPMT Migration Module 
    Import-Module Microsoft.SharePoint.MigrationTool.PowerShell 
      
    # Register the SPMT session with SPO credentials 
    Register-SPMTMigration -SPOCredential $SPOCredential -Force 
      
    # Add two tasks into the session. One is SharePoint migration task, and another is 
    # File Share migration task. 
    Add-SPMTTask -SharePointSourceCredential $SPCredential -SharePointSourceSiteUrl $SourceSiteUrl  -TargetSiteUrl $SPOUrl -MigrateAll 
    Add-SPMTTask -FileShareSource $FileshareSource -TargetSiteUrl $SPOUrl -TargetList $TargetListName 
      
    # Start Migration in the console. 
    Start-SPMTMigration  
    

    I hope this helps. 


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".    

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.