Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastiantecsi/ec6cb837a1b8f3b71406695817525ea3 to your computer and use it in GitHub Desktop.
Save sebastiantecsi/ec6cb837a1b8f3b71406695817525ea3 to your computer and use it in GitHub Desktop.
# Root path to look 'orphan' items under - update here as needed
cd 'master:/sitecore/media library'
$counter = 0
$itemsToProcess = Get-ChildItem -Recurse . | Where-Object { $_.TemplateName -ne 'Media Folder' }
if ($itemsToProcess -ne $null) {
$itemsToProcess | ForEach-Object {
$referrers = Get-ItemReferrer -Item $_ | measure
if ($referrers.Count -eq 0) {
$counter++
Write-Host $_.Paths.FullPath 'no referrers'
# commented out for safety reasons :)
# $_ | Remove-Item;
}
}
}
Write-Host $counter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment