1

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?

1
  • Did the answer solve your issue @HoffsTech? Sep 7, 2017 at 19:18

1 Answer 1

4

When I use the built-in command Get-ItemReferrer I do not see inherited items.

Avoid writing your own function and use the OOTB one.

# Get the Sample Inner Sublayout item
$item = Get-Item "master:" -ID "{CE4ADCFB-7990-4980-83FB-A00C1E3673DB}"
Get-ItemReferrer -Item $item

Output

Referrers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.