$placeholderMappings =@(@("/old-placeholder","/new-placeholder"),@("/another-old-placeholder","/new-placeholder"))$rootItem =Get-Item-Path master:/sitecore/content/Home$defaultLayout =Get-LayoutDevice"Default"# Toggle for whether to update Shared or Final Layout$useFinalLayout =$True# If set to true, the script will only list the renderings that need fixing, rather than fixing them.$reportOnly =$Falseforeach ( $item inGet-ChildItem-Item $rootItem -Recurse ){# Only interested in items that have a layoutif (Get-Layout $item) {foreach( $mapping in $placeholderMappings ) {# Get renderings in this item that have renderings in the placeholder we want to update $renderings =Get-Rendering-Item $item -Placeholder ($mapping[0] +'/*') -Device $defaultLayout -FinalLayout:$useFinalLayoutforeach ( $rendering in $renderings ) {# Only update the rendering if we're not in "Report Only" modeif (!$reportOnly) {# Update the placeholder in the rendering and set it back in the item $rendering.Placeholder = $rendering.Placeholder -replace $mapping[0], $mapping[1]Set-Rendering-Item $item -Instance $rendering -FinalLayout:$useFinalLayout }Write-Host"$($item.FullPath) - Rendering $($rendering.UniqueID) - Placeholder: $($mapping[0]) --> $($mapping[1])" } } }}
Remove datasource from rendering
Example: The following removes a datasource from a rendering on the FinalLayout.