Skip to main content
All CollectionsMigratePowerShellTips and tricks
Run an incremental migration in PowerShell
Run an incremental migration in PowerShell
Updated this week

You can arrange your script to perform a second migration where only the newer items in the source are copied.

Index

Details

Incremental update in PowerShell is the equivalent of using Copy if newer (incremental) in the copy settings of ShareGate Migrate.

The incremental update parameter will only copy list items and documents in your lists and libraries that are newer than their counterparts in the destination.

Tip: We recommend reading the Copy if newer (incremental) article to understand how the feature works and the limitations before using the setting in your script.

How-to

Run a normal PowerShell migration, and then run the operation again with a modified script.

You can modify your script to run an incremental copy with these steps:

  1. Define your copy settings to use incremental copy in a new variable by typing the following line at the beginning of your script:
    โ€‹

    $copysettings = New-CopySettings -OnContentItemExists IncrementalUpdate
  2. Add -CopySettings $copysettings to your copy line:

    Copy-Content -SourceList $srcList -DestinationList $dstList -CopySettings $copysettings

Examples

You can refer to these examples to better understand how to adapt your script to perform an incremental migration.

With a single migration script

A Copy-Content script using incremental copy:

Import-Module Sharegate$copysettings = New-CopySettings -OnContentItemExists IncrementalUpdate$srcSite = Connect-Site -Url "http://myfarm1/sites/mysourcesite"$dstSite = Connect-Site -Url "http://myfarm1/sites/mydestinationsite"$srcList = Get-List -Name "mysrclist" -Site $srcSite$dstList = Get-List -Name "mydstlist" -Site $dstSiteCopy-Content -SourceList $srcList -DestinationList $dstList -CopySettings $copysettings

With a multiple migration script using a foreach loop statement

An Import-Document script with a foreach loop statement using incremental copy:

Import-Module Sharegate$csvFile = "C:\MigrationPlanning\onedrivemigration.csv"$table = Import-Csv $csvFile -Delimiter ","$mypassword = ConvertTo-SecureString 'mypassword' -AsPlainText -Force$copysettings = New-CopySettings -OnContentItemExists IncrementalUpdateSet-Variable dstSite, dstListforeach ($row in $table) {    Clear-Variable dstSite    Clear-Variable dstList    $dstSite = Connect-Site -Url $row.ONEDRIVEURL -Username "myusername" -Password $mypassword    $dstList = Get-List -Name "Documents" -Site $dstSite    Import-Document -SourceFolder $row.DIRECTORY -DestinationList $dstList -CopySettings $copysettings}
Did this answer your question?