Copy-SPPItem

Top  Previous  Next

Copies SharePoint list items, documents and folders with full fidelity to any destination list folder within the same SharePoint farm. Items can be copied across all boundaries in SharePoint including site collections and Web applications.

Syntax

Copy-SPPItem [-Source] <SPObjectPipeBind> [-Target] <SPObjectPipeBind> [-ContentTypeMappings <string[]>] [-DisableTransactionLimits <SwitchParameter>] [-ExcludeProperties <string[]>] [-ExcludeEmptyFolders <SwitchParameter>] [-FileExistAction <string>] [-IgnoreWarnings <SwitchParameter>] [-IncludePermissions <SwitchParameter>] [-IncludeTimeStamps <SwitchParameter>] [-IncludeUsers <SwitchParameter>] [-IncludeVersions <SwitchParameter>] [-Item <string[]>] [-PropertyMappings <string[]>] [-Recursive <SwitchParameter>] [<CommonParameters>]

Parameters

Parameter

Required

Type

Description

Source

Yes

SPObjectPipeBind

SharePoint source location. Possible values:

SPFile or SPListItem object to copy.
SPFolder object to copy specified items from. Use the Item option to specify one or more items.
String object with the absolute URL address of the SPFile or SPListItem object to copy.
String object with the absolute URL address of the SharePoint list folder to copy items from. Use the Item option to specify one or more items.

Target

Yes

SPObjectPipeBind

SharePoint destination location. Possible values:

SPFile object to copy to.
SPFolder object to copy specified items to. Use the Item option to specify one or more items.
String object with the absolute URL address of the SPFile object to copy to.
String object with the absolute URL address of the SharePoint list folder to copy items to. Use the Item option to specify one or more items.

Item

No

String Array

Array of source items to copy. The items can be specified by their URL, integer id or Guid. The URLs can be folder relative, site relative or server relative. Finally, it is also possible to include simple wildcards like * and *.* and *.pdf and *partialfilename*. Specify the Recursive switch parameter to also apply the wildcard(s) to items in sub folders.

ContentTypeMappings

No

String Array

Array of strings with content type mappings in the format; SourceName:TargetName or SourceId:TargetId

List item content types are in turn mapped as specified on all item copies.

PropertyMappings

No

String Array

Array of strings with property mappings in the format; SourceName:TargetName

List item fields and property bag entries are in turn mapped as specified on all item copies.

ExcludeProperties

No

String Array

Array of strings with the internal names of metadata properties and fields to exclude on all item copies.

FileExistAction

No

String

Action on existing files in the destination. Possible values:

AddAsNewVersion: Add the copied document as a new version. Requires versioning to be enabled in the destination list.
Overwrite: Replace any existing documents. Use the IgnoreWarnings switch to continue copying on file overwrite warnings.
Rename: Preserve any existing documents and copy with a new file name.
Skip: Preserve any existing documents and skip copying documents with the same file names.

Default action is Overwrite.

ExcludeEmptyFolders

No

SwitchParameter

Do not copy empty folders.

IgnoreWarnings

No

SwitchParameter

Do not abort the copy operation on any validation warnings detected before items are copied.

IncludePermissions

No

SwitchParameter

Preserves any item level permissions on the copied items. Inherited permissions are not affected.

IncludeTimeStamps

No

SwitchParameter

Preserves the item created time and item last modified time on the copied items.

IncludeUsers

No

SwitchParameter

Preserves the item created by user and item last modified by user on the copied items.

IncludeVersions

No

SwitchParameter

Preserves the complete version history on the copied items. Requires the destination list to have the same versioning settings as the source list.

Recursive

No

SwitchParameter

Applies any specified item wildcard(s) recursively to items in sub folders.

DisableTransactionLimits

No

SwitchParameter

Disables the CopyMove transaction limits for the total item count and the total item size in MB that can be copied in one transaction. Use this switch when copying large lists and libraries that exceed the transaction limits configured on the global CopyMove settings page in Central Administration. However, the transaction may as a result take a long time to complete and consume a significant amount of memory.

Examples

Copy a single file with default options.

Copy-SPPItem "https://teams.mydomain.net/sites/site1/docs/document.ext" "https://teams.mydomain.net/sites/site2/docs/document.ext"

Copy a single file and ignore warnings like the file overwrite warning.

Copy-SPPItem "https://teams.mydomain.net/sites/site1/docs/document.ext" "https://teams.mydomain.net/sites/site2/docs/document.ext" -IgnoreWarnings

Copy a single file and add it as a new version if the destination file already exists.

Copy-SPPItem "https://teams.mydomain.net/sites/site1/docs/document.ext" "https://teams.mydomain.net/sites/site2/docs/document.ext" -FileExistAction AddAsNewVersion

Copy a single file and rename it on the destination.

Copy-SPPItem "https://teams.mydomain.net/sites/site1/docs/document.ext" "https://teams.mydomain.net/sites/site2/docs/newdocument.ext"

Copy two documents by filename.

Copy-SPPItem
 -Source "https://teams.mydomain.net/sites/site1/Shared Documents"
 -Target "https://teams.mydomain.net/sites/site2/Shared Documents"
 -Item "Document.docx","Presentation.pptx"

Copy three documents by list item id.

Copy-SPPItem
 -Source "https://teams.mydomain.net/sites/site1/Shared Documents"
 -Target "https://teams.mydomain.net/sites/site2/Shared Documents"
 -Item 432,736,789

Copy PDF files by a single wildcard.

Copy-SPPItem "https://teams.mydomain.net/sites/site1/docs/*.pdf" "https://teams.mydomain.net/sites/site2/docs"

Recursively copy files by mutliple wildcards..

 

Copy-SPPItem
 -Source "https://teams.mydomain.net/sites/site1/Shared Documents"
 -Target "https://teams.mydomain.net/sites/site2/Shared Documents"
 -Item *.docx,*.pptx

 -Recursive