Home Gitesh Portfolio Blog About Me Gallery Contact

Sitecore: Powershell query to replace the layout of items in site tree

With this powershell command you will be replace layout of items in site tree.

 
$items = Get-ChildItem -Path "master:/sitecore/content/Test/Home" -Recurse
 
$device = Get-LayoutDevice -Default
$layout = Get-Item -Path 'master:\sitecore\layout\Layouts\Project\Test\SXALayout'
 
foreach ( $item in $items ) 
{
   write-host $item.Name
   Set-Layout -Item $item -Device $device -Layout $layout | Out-Null
}
Posted: 19/07/2022 5:45:23 p.m. by Gitesh Shah | with 0 comments