Skip to main content
edited tags
Link
Gatogordo
  • 20.3k
  • 2
  • 39
  • 100
Source Link

Sitecore Powershell script to find items that break inheritance

I need to write a Powershell script to find items that refer to a specific composite component and break inheritance for presentation. If I go to the Navigation Tab in the Content Editor and click Links I get a list of these items but I want to filter out the ones that are marked as [Inherited].

Here's my script:

$props = @{
   InfoTitle = "Referrers"
    InfoDescription = "Lists all items that are using this item"
    PageSize = 25
}

function Get-ItemReferrers {
    $item = Get-Item -Path "/sitecore/content/Shared/Composite components/Header"
    $linkDb = [Sitecore.Globals]::LinkDatabase
    $links = $linkDb.GetReferrers($item)
    foreach($link in $links){
        $linkedItem = Get-Item -Path master:\ -ID $link.SourceItemID
        $linkedItem
    }
}

$items = Get-ItemReferrers
$items | Show-ListView @props -Property @{Label="Name"; Expression={$_.DisplayName} },
        @{Label="Path"; Expression={$_.ItemPath} },
        @{Label="Inheritance"; Expression={$_."__Renderings"} },
        @{Label="Updated"; Expression={$_.__Updated} },
        @{Label="Updated by"; Expression={$_."__Updated by"} },
        @{Label="Created"; Expression={$_.__Created} },
        @{Label="Created by"; Expression={$_."__Created by"} }

Close-Window

I have tried a number of fields for the Inheritance field but I don't think that is stored in a field. How do I tell if the item does not inherit presentation from standard values?