Editing Items
This page covers all methods for updating Sitecore items using SPE, from simple property changes to complex field type handling and bulk operations.
Overview
SPE provides multiple ways to edit items, each suited to different scenarios:
Automated Properties - Simple, intuitive syntax for single-field updates
Set-ItemProperty - PowerShell-standard cmdlet for property updates
BeginEdit/EndEdit - Explicit editing for multiple fields or special cases
BulkUpdateContext - High-performance updates for large datasets
Automated Properties
The most convenient way to edit items is through SPE's automated properties. These properties automatically handle BeginEdit and EndEdit operations.
Example: Update a field using automated properties.
$item = Get-Item -Path "master:\content\home"
$item.Title = "New Title"Example: Update a field with spaces in the name.
$item = Get-Item -Path "master:\content\home"
$item."Closing Date" = [datetime]::TodayExample: Update system fields.
Example: Dynamically reference fields by variable.
Using Set-ItemProperty
The PowerShell-standard approach using Set-ItemProperty is also supported.
Example: Update a property using Set-ItemProperty.
Manual Edit Context
For multiple field updates or special scenarios, use explicit BeginEdit and EndEdit calls.
Example: Update multiple fields in a single edit context.
Always match BeginEdit() with EndEdit(). If an error occurs between them, the item remains locked. Consider using try/finally blocks for safety.
Example: Safe edit context with error handling.
Working with Field Types
SPE provides intelligent handling for different Sitecore field types through automated properties.
DateTime Fields
DateTime fields automatically convert between Sitecore's string format and .NET DateTime objects.
Example: Read and write DateTime fields.
Image Fields
Image fields accept item references from the Media Library.
Example: Assign an image to an Image field.
Link Fields (General Link)
Link fields accept item references and automatically create the link XML.
Example: Assign a content item to a GeneralLink field.
Multi-Value Fields
Multi-value fields (Multilist, Treelist, etc.) accept arrays of items.
Example: Assign multiple items to a list field.
Result in Content Editor:

Accessing Typed Fields
Use the ._ or .PSFields property to access strongly-typed field objects.
Example: Access typed Image field properties.
Example: Access typed LinkField properties.
Output:
Example: Find all TextField instances on an item.
When to Use Each Method
Use Automated Properties When:
Updating a single field or a few fields
Readability is important
Working with small datasets
Example:
Use BeginEdit/EndEdit When:
Updating many fields on a single item
Needing explicit control over save timing
Working with system properties (like BranchId)
Example:
Use BulkUpdateContext When:
Updating many items (hundreds or thousands)
Performance is critical
You need to bypass certain Sitecore events
Example:
Automated properties call BeginEdit/EndEdit on every assignment, which can impact performance when updating many fields. Use explicit BeginEdit/EndEdit for multiple updates on the same item.
Bulk Update Patterns
Pattern: Update Items with BulkUpdateContext
Pattern: Update with Progress Reporting
Pattern: Conditional Updates
Pattern: Update from CSV Data
Using Context Switchers
SPE provides the New-UsingBlock function for working with Sitecore context switchers and disposable objects.
Example: Generate relative URL with site context.
Common Context Switchers
Use these classes with New-UsingBlock for various scenarios:
Sitecore.SecurityModel.SecurityDisabler- Bypass security checksSitecore.Data.BulkUpdateContext- Optimize bulk updatesSitecore.Globalization.LanguageSwitcher- Switch language contextSitecore.Sites.SiteContextSwitcher- Switch site contextSitecore.Data.DatabaseSwitcher- Switch database contextSitecore.Security.Accounts.UserSwitcher- Switch user contextSitecore.Data.Items.EditContext- Item editing contextSitecore.Data.Proxies.ProxyDisabler- Disable proxiesSitecore.Data.DatabaseCacheDisabler- Disable database cacheSitecore.Data.Events.EventDisabler- Disable events
Example: Read items with security disabled (use with caution).
Example: Update items with events disabled.
Advanced Editing Scenarios
Update Items in Different Language
Update Specific Version
Copy Field Values Between Items
Update Standard Values
Performance Optimization
Avoid: Repeated Automated Property Updates
Prefer: Explicit BeginEdit/EndEdit
Best: BulkUpdateContext for Large Datasets
Common Pitfalls
Pitfall: Forgetting to End Edit
Pitfall: Modifying System Fields Without Care
Pitfall: Assuming Item Exists
See Also
Retrieving Items - Find items to edit
Best Practices - Performance optimization
Item Languages - Manage language versions
Appendix - Common Commands - Full cmdlet reference
References
Last updated