find referrers to selected item and report
Simple one here - find all items that refer to a selected item. You could just use the Links button for this; but it's a lot quicker via PSE.
$dbs = @{
"web" = "web"
"master" = "master"
}
$defaultPath = "/sitecore"
$item = "/sitecore/"
$database = "web"
$result = Read-Variable -Parameters @(
@{
Name = "database"
Title = "Database"
Tooltip = "Select the database to scan."
Options = $dbs
Value = "web"
},
@{
Name = "item";
Title = "Item Path";
Tooltip = "Enter the path to the item";
Editor = "item";
Source = $defaultPath
}
) -Title "Select Item" -Description "Choose the item to find referrers for" -OkButtonName "OK" -CancelButtonName "Cancel"
if ($result -ne "ok") {
Write-Host "Operation cancelled"
Exit
}
Write-Host "You have selected item: $($item.Paths.Path) in $database database."
# Check if root path has been changed from default
if($item.Paths.Path -eq $defaultPath) {
$confirmResult = Show-Confirm -Title "The root path has not been changed from $($item.Paths.Path) - are you sure you want to proceed?"
if($confirmResult -ne "yes") {
Exit
}
}
Write-Host "Finding referrers for item: $($item.ItemPath) in $database database..."
$img = Get-Item -Path "$($database):$($item.ItemPath)" -Version latest -Language "en-GB"
$referrers = Get-ItemReferrer -Item $img
$reportProps = @{
Title = "Item referrer report"
InfoTitle = "Items found linking to the specified item in the $($database) db"
InfoDescription = "Report shows all items that are linked to the specified item in the $($database) db"
PageSize = 50
}
$referrers | Show-ListView @reportProps -Property @{Label = "Item Name"; Expression = { $_.Name } },
@{Label = "Referrer Path"; Expression = { $_.ItemPath } }
Close-Window