Note: PowerShell integration requires a ShareGate Migrate Pro or Enterprise subscription. It is not available on the Essentials plan.
Command
Copy-Content
Description
The command to copy content from one SharePoint list or library to another.
Note: Since Insane mode is used by default (unless -NormalMode is specified), the command waits for the Microsoft 365 Azure import to complete before returning by default. Use -NoWaitForImportCompletion to return immediately after local processing instead; in that case, the returned result is provisional (the import isn't reflected in it yet). Use Wait-ImportCompletion, or keep the current PowerShell session running, to know when the import actually finishes. The previous -WaitForImportCompletion switch is now deprecated, since waiting for completion is the default behavior again.
Tips:
To learn how to adapt your
Copy-Contentscript to perform an incremental migration, see Run an incremental migration in PowerShell.To learn how to use copy options with PowerShell, see Copy options in PowerShell.
Examples
Copy all content from a source list to a destination list.
$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 $dstSite
Copy-Content -SourceList $srcList -DestinationList $dstList
Copy content from a specific source view.
Copy-Content -SourceList $srcList -DestinationList $dstList -SourceView "My View"
Copy content using an existing property template, calling it by name.
Copy-Content -SourceList $srcList -DestinationList $dstList -TemplateName "mypropertytemplate"
Note: This example uses a template already created for your source and destination, and calls it by name. To learn how to define a new template in PowerShell, see New Property Template.
Copy content from a specific source folder to a destination folder.
Copy-Content -SourceList $srcList -DestinationList $dstList -SourceFolder "MyFolder" -DestinationFolder "MyFolder/MySubFolder"
Note: To migrate a folder and its content, use -SourceFilePath instead, as shown in a later example.
Copy content using an Excel or CSV file for metadata.
Copy-Content -SourceList $srcList -DestinationList $dstList -ExcelFilePath "c:\Users\myUser\Desktop\myExcelFile.xslx"
Note: Use this example to copy your content based on an Excel spreadsheet.
Copy specific files by path.
Copy-Content -SourceList $srcList -DestinationList $dstList -SourceFilePath "Document1.txt","Folder/Document2.txt"
Note: -SourceFilePath can be a file, folder, or document set. The path is always relative to the library you specify in your script.
Copy specific files by path to a destination folder.
Copy-Content -SourceList $srcList -DestinationList $dstList -SourceFilePath "Document1.txt","Folder/Document2.txt" -DestinationFolder "MyDestinationFolder"
Copy specific items by ID.
Copy-Content -SourceList $srcList -DestinationList $dstList -SourceItemId 2,6,100
Copy specific items by ID to a destination folder.
Copy-Content -SourceList $srcList -DestinationList $dstList -SourceItemId 2,6,100 -DestinationFolder "MyDestinationFolder"
Run a pre-check before copying all content.
Copy-Content -SourceList $srcList -DestinationList $dstList -WhatIf
Copy all content and include sensitivity labels applied to files, when both source and destination are SharePoint Online.
Copy-Content -SourceList $srcList -DestinationList $dstList -IncludeContentSensitivityLabel
Copy content without waiting for the Microsoft 365 Azure import to complete, then use Wait-ImportCompletion to know when it's finished.
$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 $dstSite
Copy-Content -SourceList $srcList -DestinationList $dstList -NoWaitForImportCompletion
Wait-ImportCompletion
Syntax
These are sets of compatible parameters for the Copy-Content command.
Copy-Content
-SourceList <List>-DestinationList <List>[-TemplateName <String>][-SourceView <String>][-SourceFolder <Uri>][-IncludeContentSensitivityLabel <SwitchParameter>][-DestinationFolder <Uri>][-NormalMode <SwitchParameter>][-NoWaitForImportCompletion <SwitchParameter>][-WhatIf <SwitchParameter>][-CopySettings <CopySettings>][-MappingSettings <MappingSettings>][-TaskName <String>]
Copy-Content
-SourceList <List>-DestinationList <List>-ExcelFilePath <String>[-TemplateName <String>][-IncludeContentSensitivityLabel <SwitchParameter>][-DestinationFolder <Uri>][-NormalMode <SwitchParameter>][-NoWaitForImportCompletion <SwitchParameter>][-WhatIf <SwitchParameter>][-CopySettings <CopySettings>][-MappingSettings <MappingSettings>][-TaskName <String>]
Copy-Content
-SourceList <List>-DestinationList <List>-SourceFilePath <Uri[]>[-TemplateName <String>][-SourceFolder <Uri>][-IncludeContentSensitivityLabel <SwitchParameter>][-DestinationFolder <Uri>][-NormalMode <SwitchParameter>][-NoWaitForImportCompletion <SwitchParameter>][-WhatIf <SwitchParameter>][-CopySettings <CopySettings>][-MappingSettings <MappingSettings>][-TaskName <String>]
Copy-Content
-SourceList <List>-SourceItemId <Int32[]>-DestinationList <List>[-TemplateName <String>][-IncludeContentSensitivityLabel <SwitchParameter>][-DestinationFolder <Uri>][-NormalMode <SwitchParameter>][-NoWaitForImportCompletion <SwitchParameter>][-WhatIf <SwitchParameter>][-CopySettings <CopySettings>][-MappingSettings <MappingSettings>][-TaskName <String>]
Copy-Content
-Template <PropertyTemplate>-SourceList <List>-DestinationList <List>[-SourceView <String>][-SourceFolder <Uri>][-IncludeContentSensitivityLabel <SwitchParameter>][-DestinationFolder <Uri>][-NormalMode <SwitchParameter>][-NoWaitForImportCompletion <SwitchParameter>][-WhatIf <SwitchParameter>][-CopySettings <CopySettings>][-MappingSettings <MappingSettings>][-TaskName <String>]
Copy-Content
-Template <PropertyTemplate>-SourceList <List>-DestinationList <List>-ExcelFilePath <String>[-IncludeContentSensitivityLabel <SwitchParameter>][-DestinationFolder <Uri>][-NormalMode <SwitchParameter>][-NoWaitForImportCompletion <SwitchParameter>][-WhatIf <SwitchParameter>][-CopySettings <CopySettings>][-MappingSettings <MappingSettings>][-TaskName <String>]
Copy-Content
-Template <PropertyTemplate>-SourceList <List>-DestinationList <List>-SourceFilePath <Uri[]>[-SourceFolder <Uri>][-IncludeContentSensitivityLabel <SwitchParameter>][-DestinationFolder <Uri>][-NormalMode <SwitchParameter>][-NoWaitForImportCompletion <SwitchParameter>][-WhatIf <SwitchParameter>][-CopySettings <CopySettings>][-MappingSettings <MappingSettings>][-TaskName <String>]
Copy-Content
-Template <PropertyTemplate>-SourceList <List>-SourceItemId <Int32[]>-DestinationList <List>[-IncludeContentSensitivityLabel <SwitchParameter>][-DestinationFolder <Uri>][-NormalMode <SwitchParameter>][-NoWaitForImportCompletion <SwitchParameter>][-WhatIf <SwitchParameter>][-CopySettings <CopySettings>][-MappingSettings <MappingSettings>][-TaskName <String>]
You can get the syntax of any command in PowerShell with this script:
Get-Command Copy-Content -SyntaxParameters
Parameters
-CopySettings <CopySettings>
Specifies the copy settings.
Required? | False |
Default value | None |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-DestinationFolder <Uri>
Specifies the folder path at the destination. Note: This parameter cannot be used to create new folders at the destination.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-DestinationList <List>
Specifies the destination list.
Required? | True |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-ExcelFilePath <String>
Specifies the path of the file used for metadata. Supported formats are Excel and CSV.
Required? | True |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | TemplateNameExcelFilePath, TemplateExcelFilePath |
Aliases | None |
-IncludeContentSensitivityLabel <SwitchParameter>
Specifies that sensitivity labels applied to content - files stored in document libraries (folders are excluded) - are copied to the destination using the persisted sensitivity label mapping. Both source and destination must be SharePoint Online.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-MappingSettings <MappingSettings>
Specifies the mapping settings.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-NormalMode <SwitchParameter>
Specifies that the normal mode should be used.
Note: Insane mode is always used by default in PowerShell.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-NoWaitForImportCompletion <SwitchParameter>
Specifies that the command returns after local processing without waiting for the Azure Insane mode import to complete.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-SourceFilePath <Uri[]>
Specifies the source file path. -SourceFilePath will not work for more than 155 file paths.
Required? | True |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | TemplateNameSourceFilePath, TemplateSourceFilePath |
Aliases | None |
-SourceFolder <Uri>
Specifies the folder path at the source.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | Default, TemplateNameSourceFilePath, Template, TemplateSourceFilePath |
Aliases | None |
-SourceItemId <Int32[]>
Specifies the source item ID.
Required? | True |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | TemplateNameSourceItemId, TemplateSourceItemId |
Aliases | None |
-SourceList <List>
Specifies the source list.
Required? | True |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-SourceView <String>
Specifies the source view, using the title, the file name or the URL of the view.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | Default, Template |
Aliases | None |
-TaskName <String>
Specifies a name for the task.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
-Template <PropertyTemplate>
Specifies the property template. To use the built-in "Full Copy" template, do not specify this parameter.
Required? | True |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | Template, TemplateExcelFilePath, TemplateSourceFilePath, TemplateSourceItemId |
Aliases | None |
-TemplateName <String>
Specifies the property template to use by its name. You can use ShareGate to configure property templates for the specified list (see Import Property Mapping or New Property Template). To use the built-in "Full Copy" template, do not specify this parameter.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | Default, TemplateNameExcelFilePath, TemplateNameSourceFilePath, TemplateNameSourceItemId |
Aliases | None |
-WhatIf <SwitchParameter>
Specifies that a pre-check is executed instead of a migration. For more information, see Run a Pre-Check in PowerShell.
Required? | False |
Default value | None |
Accept pipeline input? | False |
Accept wildcard characters? | False |
Parameter set name | (All) |
Aliases | None |
