Working with Items

The Sitecore PowerShell Extensions (SPE) module provides powerful cmdlets for managing Sitecore content items. This section covers everything you need to know about working with items programmatically.

Quick Start

The core item management cmdlets mirror standard PowerShell conventions:

Cmdlet
Purpose
Example

Get-Item

Retrieve a single item

Get-Item -Path "master:\content\home"

Get-ChildItem

Retrieve children and descendants

Get-ChildItem -Path "master:\content" -Recurse

New-Item

Create a new item

New-Item -Path "master:\content\home" -Name "Page" -ItemType "Sample/Sample Item"

Set-ItemProperty

Update item properties

Set-ItemProperty -Path "master:\content\home" -Name "Title" -Value "Welcome"

Copy-Item

Duplicate an item

Copy-Item -Path "master:\content\home\source" -Destination "master:\content\home\target"

Move-Item

Transfer an item

Move-Item -Path "master:\content\home\old" -Destination "master:\content\home\new"

Remove-Item

Delete or recycle an item

Remove-Item -Path "master:\content\home\demo" -Permanently

Documentation Topics

Fundamentals

Before working with items, understand these foundational concepts:

  • Providers - PowerShell providers and navigating Sitecore databases

  • Variables - Built-in variables available in SPE scripts

Core Item Operations

Learn how to perform essential item operations:

Specialized Operations

Handle specific aspects of item management:

Advanced Topics

Optimize your scripts and follow best practices:

  • Best Practices - Performance optimization, bulk operations, and coding patterns

Common Patterns

Pattern: Find and Update Items

Pattern: Bulk Create Items

Pattern: Copy Content Between Databases

Pattern: Audit and Report

Dynamic Parameters

SPE extends standard PowerShell cmdlets with dynamic parameters specific to Sitecore. These parameters appear based on context:

  • Language - Specify language versions (-Language "en-US" or -Language *)

  • Version - Specify item versions (-Version 2 or -Version *)

  • Database - Target specific databases when using IDs

  • Query - Execute Sitecore queries (query: or fast:)

  • ID - Work with items by GUID

  • Uri - Use ItemUri for complete item identification

See the Retrieving Items page for detailed parameter documentation.

Path Formats

SPE supports multiple path formats for flexibility:

Note: The /sitecore portion is optional when using provider paths.

Working with Field Types

SPE provides intelligent handling of Sitecore field types through automated PowerShell properties:

See Editing Items for comprehensive field type examples.

Performance Considerations

When working with large datasets, consider these performance tips:

  • Use fast: queries instead of Get-ChildItem -Recurse when possible

  • Leverage BulkUpdateContext for multiple updates

  • Use SecurityDisabler judiciously for read operations

  • Batch operations and provide progress feedback

See Best Practices for detailed performance guidance.

See Also

Getting Help

Last updated