Last active
February 6, 2017 13:21
-
-
Save AdamNaj/3b1f7c9519c3c36ecb8ccbe5401f3966 to your computer and use it in GitHub Desktop.
Template Usage Audit script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$templates = [Sitecore.Data.Managers.TemplateManager]::GetTemplates((Get-Database "master")) | |
$templates | %{ | |
if($_ -ne $null -and -not ($_.GetType().Name -match "ErrorRecord") -and -not ($_.Value.FullName.StartsWith("System"))){ | |
try { | |
$template = $_.Value | |
$templateItem = Get-Item master:\ -ID $template.ID | |
$items = @() + (Get-ItemReferrer -Database "master" -ID $template.ID | ? { $template.Name -ne "__Standard Values"}) | |
Add-Member -InputObject $templateItem -MemberType NoteProperty -Name "FullName" -Value ($template.FullName) | |
} catch { | |
Add-Member -InputObject $templateItem -MemberType NoteProperty -Name "UsageCount" -Value "Error getting references" | |
return $templateItem | |
} | |
Add-Member -InputObject $templateItem -MemberType NoteProperty -Name "UsageCount" -Value ($items.count) | |
return $templateItem | |
} | |
} | | |
Sort-Object UsageCount -Descending | | |
Show-ListView -Property FullName, UsageCount |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment