[Sitecore Powershell] #1 — Update Items based on template and path

Bernard Lim
Sitecore Series
Published in
1 min readJun 30, 2018

Objective

Update value of a specific field on all child items that are based on a specific template, starting from the specific content item path

Code Excerpt

Code Explanation

$contentPath : Path of content item on tree to start querying from
$templateID : ID of template that your targeted items will be based upon
$fieldName : Field name of item to be updated
$newFieldValue : New value of field which will replace existing values

  • Starting off the specified $contentPath, get all child items and recurse and grab all items where template is $templateID.
  • Loop through each item and update item’s $fieldName value to $newFieldValue
Photo by Ilija Boshkov on Unsplash

--

--

Bernard Lim
Sitecore Series

@thebernardlim. Code. Sitecore. Fitness. Food. Random