bulk update item property
This PS script will iterate over a list of items and change a given property, then publish.
## Set a list of pages where we want to change the prop
$itemPathsToEdit = (
"master:/sitecore/content/path/to/item1",
"master:/sitecore/content/path/to/item2",
"master:/sitecore/content/path/to/item3"
)
$existingPropItemId = "{79C5D158-68E5-4775-AE3F-8B672D53D64D}";
$destinationPropItemId = "{4B56828B-F8D3-4C54-B771-6618F2699229}";
$propToUpdate = "PROP";
## Iterate over the list
foreach($itemPath in $itemPathsToEdit)
{
## Get the item by path and check it exists
$item = Get-Item -Path $itemPath
if($item -ne $null)
{
## Ensure the prop is set to what we expect
if($item.Fields[$propToUpdate].Value -eq $existingPropItemId)
{
Write-Host "Updating $propToUpdate of item at path:" $itemPath
## Open editing, set new prop value, close editing
$item.Editing.BeginEdit()
$item.Fields[$propToUpdate].Value = $destinationPropItemId
$item.Editing.EndEdit()
## Publish item
Publish-Item -Id $item.ID -PublishMode Full -Language '*' -RepublishAll -Verbose
}
}
}
Write-Host "Complete"