0

I need a PowerShell script or a .aspx page to get the list of items which has no reference or link to it. Can anyone help with this?

2
1

If you are using powershell you can take a look at the Get-ItemReferrer documentation https://doc.sitecorepowershell.com/appendix/common/get-itemreferrer that can be used check if an item has any referrences to it. I have used the following powershell script:

$items = Get-ChildItem -Path 'master:/sitecore/content/Home' -Recurse
$results = New-Object System.Collections.ArrayList

foreach ($item in $items) {
    $links = $item | Get-ItemReferrer

    if ($links.Count -eq 0) {
        [void]$results.Add($item)
    }
}

$results | Format-Table Name, @{ Label = 'Path'; Expression={ $_.Paths.Path } } 

In C# you can use ItemLink[] itemLinks = Globals.LinkDatabase.GetReferrers(item); to get all referrers of a specific item. I would also recommend to run Rebuild Link databases from control panel prior to running the reports to make sure Link Database is up to date.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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