Skip to content

Instantly share code, notes, and snippets.

@AdamNaj
Created April 20, 2016 13:32
Show Gist options
  • Save AdamNaj/035366c698ef98e1b00a574eb085e790 to your computer and use it in GitHub Desktop.
Save AdamNaj/035366c698ef98e1b00a574eb085e790 to your computer and use it in GitHub Desktop.
Template Complexity analysis
$standardFieldCount = (Get-ItemTemplate master:\).Fields.Count
Get-ChildItem master:\templates -Recurse |
? {($_.TemplateName -eq "Template") -and -not $_.FullPath.StartsWith('/sitecore/templates/System')} |
% { [Sitecore.Data.Items.TemplateItem]$template = $_
[pscustomobject]@{
Path=&{$_.FullPath};
OnThisTemplate=&{(Get-ChildItem -Path $_.Providerpath -Recurse | ? { $_.TemplateName -eq "Template Field"}).Count};
NonStandardFields =&{$template.Fields.Count- $standardFieldCount};
TotalFields=&{$template.Fields.Count}
}
} |
Sort-Object NonStandardFields -descending |
? { $_.NonStandardFields -gt 10 } |
Format-Table -auto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment