Copy-SPList

Copy a list from one site to another. Wraps the functionality of the Export-SPWeb and Import-SPWeb cmdlets.

Copy-SPList -SourceList <SPListPipeBind> -TargetWeb <SPWebPipeBind> [-DeleteSource [<SwitchParameter>]] [-Path [<String>]] [-SuppressAfterEvents [<SwitchParameter>]] [-RetargetLinks [<SwitchParameter>]] [-RetainObjectIdentity [<SwitchParameter>]] [-IncludeVersions [<Nullable`1>]] [-IncludeDescendants [<Nullable`1>]] [-UpdateVersions [<Nullable`1>]] [-CompressionSize [<Int32>]] [-IncludeDependencies [<SwitchParameter>]] [-ExcludeChildren [<SwitchParameter>]] [-UseSqlSnapshot [<SwitchParameter>]] [-Force [<SwitchParameter>]] [-HaltOnError [<SwitchParameter>]] [-HaltOnWarning [<SwitchParameter>]] [-IncludeUserSecurity [<SwitchParameter>]] [-NoFileCompression [<SwitchParameter>]] [-NoLogFile [<SwitchParameter>]] [-AssignmentCollection [<SPAssignmentCollection>]]

Parameters

1

ParameterRequiredTypeDescription
SourceListTrueSPListPipeBind

The source list to copy.

The value must be a valid URL in the form http://server_name

TargetWebTrueSPWebPipeBind

Specifies the URL or GUID of the Web containing the list to be copied.

The type must be a valid GUID, in the form 12345678-90ab-cdef-1234-567890bcdefgh; a valid name of Microsoft SharePoint Foundation 2010 Web site (for example, MySPSite1); or an instance of a valid SPWeb object.

DeleteSourceFalseSwitchParameter

Delete the source list after the copy operation completes.

PathFalseString

Specifies the name of the export file.

If the NoFileCompression parameter is used, a directory must be specified; otherwise, any file format is valid.

SuppressAfterEventsFalseSwitchParameter

RetargetLinksFalseSwitchParameter

Iterate through all links pointing to the source and retarget to the new location.

RetainObjectIdentityFalseSwitchParameter

If specified, create the new list with the same ID as the source list. The target location must be in a different content database from the source list for this to work.

IncludeVersionsFalseNullable`1

Indicates the type of file and list item version history to be included in the export operation. If the IncludeVersions parameter is absent, the Copy-SPList cmdlet by default uses a value of "LastMajor".

The type must be any one of the following versions:

-Last major version for files and list items (default)

-The current version, either the last major version or the last minor version

-Last major and last minor version for files and list items

-All versions for files and list items

IncludeDescendantsFalseNullable`1

UpdateVersionsFalseNullable`1

CompressionSizeFalseInt32

Sets the maximum file size for the compressed export files. If the total size of the exported package is greater than this size, the exported package will be split into multiple files.

IncludeDependenciesFalseSwitchParameter

ExcludeChildrenFalseSwitchParameter

UseSqlSnapshotFalseSwitchParameter

Specifies a SQL Database Snapshot will be created when the export process begins, and all exported data will be retrieved directly from the database snapshot. This snapshot will be automatically deleted when export completes.

ForceFalseSwitchParameter

Forcefully overwrites the export package if it already exists.

HaltOnErrorFalseSwitchParameter

Stops the export/import process when an error occurs.

HaltOnWarningFalseSwitchParameter

Stops the export/import process when a warning occurs.

IncludeUserSecurityFalseSwitchParameter

Preserves the user security settings.

NoFileCompressionFalseSwitchParameter

Either enables or disables file compression in the export package. The export package is stored in the folder specified by thePath parameter or Identity parameter. We recommend that you use this parameter for performance reasons. If compression is enabled, the export process can increase by approximately 30 percent.

NoLogFileFalseSwitchParameter

Suppresses the generation of an export log file. If this parameter is not specified, the cmdlet will generate an export log file in the same location as the export package. The log file uses Unified Logging Service (ULS).

It is recommended to use this parameter. However, for performance reasons, you might not want to generate a log file.

AssignmentCollectionFalseSPAssignmentCollection

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

Detailed Description

Copy a list from one site to another. Wraps the functionality of the Export-SPWeb and Import-SPWeb cmdlets.

Copyright 2016 Falchion Consulting, LLC

> For more information on this cmdlet and others:

> http://blog.falchionconsulting.com/

> Use of this cmdlet is at your own risk.

> Gary Lapointe assumes no liability.

Examples

------------------EXAMPLE------------------

PS C:\> Get-SPList "http://server_name/sites/site1/lists/mylist" | Copy-SPList -TargetWeb "http://server_name/sites/sites2"

This example copies the mylist list from site1 to site2.