Sitecore Powershell script to remove renderings of items

By Pranay
16 May '20  ·  1904 views

This post would help you to remove the renderings of multiple items in Sitecore using Sitecore Powershell script. This will remove both Shared and Final renderings of the item.

There may be a scenario where you want to remove all renderings of an item in Sitecore. Doing this manually is tedious task, hence a handy Powershell script can make our task easy. Below is the Sitecore Powershell script to remove all the renderings of a single/multiple items in Sitecore.

Is this not the script you are looking for? Then check the complete list of Sitecore Powershell scripts

Sitecore Powershell script to remove renderings of items

$props = @{
   InfoTitle = "Change Template of items"
    PageSize = 10000000

$sourcePath = "master:/sitecore/content/Home/Site2"
$items = Get-ChildItem -Path $sourcePath -Recurse
#Uncomment below two lines if you want to include the root item too.
#$rootItem = Get-Item -Path $sourcePath
#$items = $items + $rootItem

function Change-Template {

    # Logic
    foreach($item in $items)
        if ($item.TemplateId -eq "{BAAF9E6D-000F-4C58-9BDF-E0E6F04EF5A9}")
            $item.Fields["__Renderings"].Value = ""
            $item.Fields["__Final Renderings"] = ""
            Write-Host "Renderings removed for: " $item.ID " 


$items = Change-Template
$items | Show-ListView @props -Property ItemPath, ID, @{Label="Language"; Expression={$_."Language"}} 

Remove Sitecore renderings powershell script

About the author

Pranay Deegoju
Sitecore Certified Professional

A Software Engineer by profession, a part time blogger and an enthusiast programmer. You can find more about me here.

Post a comment

Recent Posts


Liked this article?

Subscribe with your email and get updates when ever a new article is posted.

By subscribing you agree to our privacy terms. We promise that we do not sell your data.