Moving and Copying Items

This page covers how to move and copy Sitecore items using SPE, including transfers within databases and between databases.

Moving Items

Use Move-Item to transfer items from one location to another. The item retains its ID and all version history.

Basic Move Operations

Example: Move an item to a new parent.

$sourcePath = "master:\content\home\sample item"
$destinationPath = "master:\content\home\moved"
Move-Item -Path $sourcePath -Destination $destinationPath

If the destination item exists, the moved item becomes a child of the destination. If the destination doesn't exist, the source item is renamed during the move.

Example: Move and rename in one operation.

# If "new-name" doesn't exist, item is moved and renamed
$oldPath = "master:\content\home\old-name"
$newPath = "master:\content\home\new-name"
Move-Item -Path $oldPath -Destination $newPath

Moving via Pipeline

Example: Get an item and move it using the pipeline.

Moving with Children

By default, Move-Item moves the item and all its descendants.

Example: Move an entire content tree.

Copying Items

Use Copy-Item to duplicate items. By default, the copy receives a new ID.

Basic Copy Operations

Example: Copy an item to a new location and change display name.

The item name in the destination path determines the new item's name. Lowercase names in the destination result in lowercase item names.

Example: Copy and return the new item.

Recursive Copying

Example: Copy an entire tree maintaining structure.

Copying Between Databases

Copy items between databases (e.g., from master to web) using transfer options.

Example: Transfer item with same ID to another database.

Transfer Options

The -TransferOptions parameter controls how items are copied between databases:

Value
Behavior

0

Keep original ID

1

Create new ID (default behavior)

2

Allow default values

4

Allow standard values

Example: Copy with new ID (default behavior).

Bulk Operations

Pattern: Move Multiple Items

Pattern: Copy Items Based on Criteria

Pattern: Reorganize Content Structure

Pattern: Copy with Progress Reporting

Maintaining Structure

Pattern: Copy Tree Maintaining Hierarchy

Dynamic Parameters

Parameter
Command
Description
Example

DestinationItem

Move-Item, Copy-Item

Parent item to receive moved/copied item

-DestinationItem $parent

FailSilently

Move-Item, Copy-Item

Suppress unauthorized access errors

-FailSilently

TransferOptions

Copy-Item

Controls ID handling (0=keep, 1=new)

-TransferOptions 0

PassThru

Copy-Item

Returns the new item

-PassThru

Recurse

Copy-Item

Includes all descendants

-Recurse

Performance Considerations

  • Batch operations - Group multiple moves/copies together

  • Use BulkUpdateContext - When copying many items with field updates

  • Progress reporting - Provide feedback for long-running operations

  • Avoid unnecessary recursion - Only use -Recurse when needed

  • Test first - Use -WhatIf parameter if available, or test in development

Common Pitfalls

Pitfall: Moving to Non-Existent Path

Pitfall: Copying Without PassThru

See Also

References

Last updated