Providers

PowerShell providers expose data stores through a consistent interface that resembles a file system. SPE extends this model with the CmsItemProvider, enabling you to navigate and manipulate Sitecore content as if it were a file system.

Understanding Providers

Run Get-PSProvider to see all available providers in your SPE session:

Get-PSProvider

Name        Capabilities                           Drives
----        ------------                           ------
Registry    ShouldProcess, Transactions            {HKLM, HKCU}
Alias       ShouldProcess                          {Alias}
Environment ShouldProcess                          {Env}
FileSystem  Filter, ShouldProcess, Credentials     {C}
Function    ShouldProcess                          {Function}
Variable    ShouldProcess                          {Variable}
Certificate ShouldProcess                          {Cert}
WSMan       Credentials                            {WSMan}
Sitecore    Filter, ExpandWildcards, ShouldProcess {master, web, core}

Built-In Providers

Sitecore

The Sitecore is the heart of SPE's Sitecore integration. It exposes Sitecore databases as PowerShell drives.

Features:

  • Navigate Sitecore content trees using paths

  • Access items by ID, query, or URI

  • Support for language and version parameters

  • Filter by template and other properties

Example: Explore the CmsItemProvider.

FileSystem Provider

The FileSystem provider allows interaction with the server's file system.

Example: Access file system from SPE.

PowerShell Drives

Drives are the access points for providers. SPE creates drives for each Sitecore database.

Sitecore Database Drives

Example: List all available drives.

Drive Structure

Each Sitecore database drive has the following structure:

The root of each drive represents /sitecore in Sitecore paths.

The text /sitecore or \sitecore is typically omitted when using the drive names such as core:, master: and web:.

Use cd or Set-Location to switch between drives and providers.

Example: Navigate between Sitecore databases.

Example: Navigate between providers.

Path Formats

The Sitecore provider supports multiple path formats for flexibility.

Sitecore Path Format

Mixed Separators

Both forward and backward slashes work interchangeably:

Relative Paths

Use relative paths when you're already in a specific location:

Provider-Specific Features

Dynamic Parameters

When using the Sitecore provider, cmdlets gain Sitecore-specific dynamic parameters:

Example: Using dynamic parameters.

Property Access

The Sitecore provider exposes Sitecore item properties through PowerShell properties:

Example: Access item properties.

Common Provider Patterns

Pattern: Work with Multiple Databases

Pattern: Compare Items Across Databases

Pattern: File System Operations

Pattern: Working Directory Management

Pattern: Cross-Provider Operations

Provider Cmdlets

Common cmdlets work across all providers:

Cmdlet
Purpose
Example

Get-Location / pwd

Show current location

Get-Location

Set-Location / cd

Change location

cd master:\content

Push-Location

Save location

Push-Location

Pop-Location

Restore location

Pop-Location

Get-Item

Get item at path

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

Get-ChildItem / ls

List children

Get-ChildItem -Path "master:\content"

Test-Path

Check if path exists

Test-Path "master:\content\home"

Testing Paths

Example: Verify item existence.

Example: Conditional operations based on existence.

Advanced Provider Usage

Using Provider Paths

Get the full provider path for an item:

Example: Access provider path.

Custom Drive Creation

While rare, you can create custom drives:

Example: Create a drive pointing to a specific location.

Provider Capabilities

Check what a provider can do:

Example: View provider capabilities.

Troubleshooting

Issue: Dynamic Parameters Not Appearing

Symptom: Parameters like -Language or -ID are not available.

Solution: Ensure you're specifying a database path:

Issue: File System Path Behavior

Symptom: cd C: doesn't go to C:\ root.

Solution: Always include the backslash for FileSystem provider root:

Issue: Path Not Found

Symptom: "Cannot find path" error.

Solution: Verify the item exists and the path is correct:

Performance Considerations

Provider vs. Direct API

The Sitecore provider adds convenience but may have overhead for large operations:

Caching

Providers may cache data. If you're seeing stale data:

See Also

References

Last updated