Skip to main content

Copy-Site

Copy a SharePoint site with PowerShell

Note: PowerShell integration requires a ShareGate Migrate Pro or Enterprise subscription. It is not available on the Essentials plan.

Command

Copy-Site

Description

The command to copy sites from a SharePoint site 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:

Examples

Merge a site with the destination site, including its subsites.

$srcSite = Connect-Site -Url "http://myfarm1/sites/mysourcesite"
$dstSite = Connect-Site -Url "http://myfarm1/sites/mydestinationsite"
Copy-Site -Site $srcSite -DestinationSite $dstSite -Merge -Subsites

Copy a site as a subsite of the destination site.

Copy-Site -Site $srcSite -DestinationSite $dstSite

Get the subsites of the source site and copy them to the destination site.

$toCopy = Get-Subsite -Site $srcSite
Copy-Site -Site $toCopy -DestinationSite $dstSite

Copy all subsites of the source site to the destination site.

Copy-Site -All -SourceSite $srcSite -DestinationSite $dstSite

Run a pre-check before copying a site as a subsite.

Copy-Site -Site $srcSite -DestinationSite $dstSite -WhatIf

Copy some subsites whose names match the specified patterns.

Copy-Site -Name MyName*,MySpecificName -SourceSite $srcSite -DestinationSite $dstSite

Copy and rename a subsite.

Copy-Site -Name MyName*,MySpecificName -SourceSite $srcSite -DestinationSite $dstSite -SiteTitle MyNewName -SiteTitleUrlSegment MyNewUrl

Merge a site with the destination site, including its subsites, and copy sensitivity labels applied to both content and structure.

Copy-Site -Site $srcSite -DestinationSite $dstSite -Merge -Subsites -IncludeStructureSensitivityLabel -IncludeContentSensitivityLabel

Copy a site 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"
Copy-Site -Site $srcSite -DestinationSite $dstSite -NoWaitForImportCompletion
Wait-ImportCompletion

Syntax

These are sets of compatible parameters for the Copy-Site command.

Copy-Site
-Site <Site[]>-DestinationSite <Site>[-Merge <SwitchParameter>][-NoNavigation <SwitchParameter>][-Subsites <SwitchParameter>][-SiteTitle <String>][-SiteTitleUrlSegment <String>][-NoContent <SwitchParameter>][-VersionLimit <Int32>][-NoCustomPermissions <SwitchParameter>][-NoWorkflows <SwitchParameter>][-NoSiteFeatures <SwitchParameter>][-NoWebParts <SwitchParameter>][-NoNintexWorkflowHistory <SwitchParameter>][-UserAlerts <SwitchParameter>][-NormalMode <SwitchParameter>][-ForceNewListExperience <SwitchParameter>][-NoCustomizedListForms <SwitchParameter>][-NoListViews <SwitchParameter>][-CopySettings <CopySettings>][-MappingSettings <MappingSettings>][-WhatIf <SwitchParameter>][-TaskName <String>][-IncludeStructureSensitivityLabel <SwitchParameter>][-IncludeContentSensitivityLabel <SwitchParameter>][-NoWaitForImportCompletion <SwitchParameter>]
Copy-Site
-Name <String[]>-SourceSite <Site>-DestinationSite <Site>[-Merge <SwitchParameter>][-NoNavigation <SwitchParameter>][-Subsites <SwitchParameter>][-SiteTitle <String>][-SiteTitleUrlSegment <String>][-NoContent <SwitchParameter>][-VersionLimit <Int32>][-NoCustomPermissions <SwitchParameter>][-NoWorkflows <SwitchParameter>][-NoSiteFeatures <SwitchParameter>][-NoWebParts <SwitchParameter>][-NoNintexWorkflowHistory <SwitchParameter>][-UserAlerts <SwitchParameter>][-NormalMode <SwitchParameter>][-ForceNewListExperience <SwitchParameter>][-NoCustomizedListForms <SwitchParameter>][-NoListViews <SwitchParameter>][-CopySettings <CopySettings>][-MappingSettings <MappingSettings>][-WhatIf <SwitchParameter>][-TaskName <String>][-IncludeStructureSensitivityLabel <SwitchParameter>][-IncludeContentSensitivityLabel <SwitchParameter>][-NoWaitForImportCompletion <SwitchParameter>]
Copy-Site
-All <SwitchParameter>-SourceSite <Site>-DestinationSite <Site>[-Merge <SwitchParameter>][-NoNavigation <SwitchParameter>][-Subsites <SwitchParameter>][-SiteTitle <String>][-SiteTitleUrlSegment <String>][-NoContent <SwitchParameter>][-VersionLimit <Int32>][-NoCustomPermissions <SwitchParameter>][-NoWorkflows <SwitchParameter>][-NoSiteFeatures <SwitchParameter>][-NoWebParts <SwitchParameter>][-NoNintexWorkflowHistory <SwitchParameter>][-UserAlerts <SwitchParameter>][-NormalMode <SwitchParameter>][-ForceNewListExperience <SwitchParameter>][-NoCustomizedListForms <SwitchParameter>][-NoListViews <SwitchParameter>][-CopySettings <CopySettings>][-MappingSettings <MappingSettings>][-WhatIf <SwitchParameter>][-TaskName <String>][-IncludeStructureSensitivityLabel <SwitchParameter>][-IncludeContentSensitivityLabel <SwitchParameter>][-NoWaitForImportCompletion <SwitchParameter>]

You can get the syntax of any command in PowerShell with this script:

Get-Command Copy-Site -SyntaxParameters

Parameters

-All <SwitchParameter>

Specifies that they all be copied.

Required?

True

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

All

Aliases

None

-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

-DestinationSite <Site>

Specifies the destination site.

Required?

True

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-ForceNewListExperience <SwitchParameter>

Specifies that the command will convert lists to the new Microsoft 365 experience when possible.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

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 sensitivity label mappings. 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

-IncludeStructureSensitivityLabel <SwitchParameter>

Specifies that sensitivity labels applied to structure objects - the site collection, its connected Microsoft 365 Group, and document libraries - are copied to the destination using the sensitivity label mappings. 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

-Merge <SwitchParameter>

Specifies merging the site with the destination site instead of adding it as a subsite. This parameter can not be used when copying more than one site.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-Name <String[]>

Specifies the name (wildcards supported).

Required?

True

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

True

Parameter set name

Name

Aliases

None

-NoContent <SwitchParameter>

Specifies that all list items, documents, folders and document sets inside the lists and libraries won't be copied.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-NoCustomizedListForms <SwitchParameter>

Specifies that customized list forms and content type forms won't be copied.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-NoCustomPermissions <SwitchParameter>

Specifies that everything will be set to inherit the permissions from its parent.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-NoListViews <SwitchParameter>

Specifies that list views won't be copied.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-NoNavigation <SwitchParameter>

Specifies that the site navigation and quick launch settings won't be preserved during the copy. If it is specified, the settings will be set to the default in the destination site.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-NoNintexWorkflowHistory <SwitchParameter>

Specifies that the history for Nintex workflows associated with the migrated objects won't be copied to the destination.

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

-NoSiteFeatures <SwitchParameter>

Specifies that all the site and site collection features that are required by the elements being copied won't be automatically activated.

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

-NoWebParts <SwitchParameter>

Specifies that the web parts won't be copied when copying pages.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-NoWorkflows <SwitchParameter>

Specifies that the workflows associated with the migrated objects won't be copied to the destination.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-Site <Site[]>

Specifies the source site to copy.

Required?

True

Default value

None

Accept pipeline input?

True (ByValue, ByPropertyName)

Accept wildcard characters?

False

Parameter set name

Default

Aliases

None

-SiteTitle <String>

Specifies the new site title. This parameter must be used with the 'SiteTitleUrlSegment' parameter and can not be used when copying more than one site.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-SiteTitleUrlSegment <String>

Specifies the new site url that is relative to its parent site. This parameter must be used with the 'SiteTitle' parameter and can not be used when copying more than one site.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-SourceSite <Site>

Specifies the source site.

Required?

True

Default value

None

Accept pipeline input?

True (ByValue, ByPropertyName)

Accept wildcard characters?

False

Parameter set name

Name, All

Aliases

None

-Subsites <SwitchParameter>

Specifies that all subsites from source site will be copied.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

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

-UserAlerts <SwitchParameter>

Specifies that the user alerts associated with the migrated objects will be copied to the destination.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-VersionLimit <Int32>

Specifies that copy the X latest version, while always conserving at least one major version.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-WhatIf <SwitchParameter>

Specifies that a pre-check will be executed instead of a migration.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

Did this answer your question?