Sitecore Powershell to update item fields

The Powershell module is one of the flexible ways to work with the Sitecore items with ease. If you have not installed the module yet, i highly recommend installing the Sitecore Powershell Extensions module from the Sitecore Marketplace

Here is a code snippet to update the Sitecore item fields:

New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) {
foreach($item in Get-ChildItem Path master:\content\MyWebsite\Folder01 Recurse) {
$item.Roles = "{C731475E-D7BF-4BE1-A323-9C059ED2DE49}|{CC6FEF3F-8C13-4EC7-8E5A-9F0E56769FED}"
$item["__Workflow state"] = "{4785314C-2C4A-4784-955B-D638CB42E994}"
$item.Editing.EndEdit() | Out-Null

view raw


hosted with ❤ by GitHub

The above script will be recursive and can reach items in the subfolder level. You could remove the “-Recurse” parameter if you are looking at the child items for the current folder.

The above script can scale to any other field updates or any other item or set of item updates.

Feel free to leave a reply here...

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: