Wednesday, April 15, 2015

SharePoint 2013: how to view default list and site templates

TIP

Presented below are PowerShell methods for extracting list and site templates.

Default List Templates
$web = Get-SPWeb http://YourSiteURL $web.ListTemplates | Select-Object name, Type_Client, FeatureID | Sort-Object Name | Format-Table -auto
Default Site Templates
Get-SPWebTemplate | Select-Object Name, Title, isHidden | Sort-Object Name | Format-Table -auto
Custom List Templates
$web = Get-SPWeb http://YourSiteURL $list = $web.Lists["List Template Gallery"] $table = New-Object system.data.datatable "MyTable" $col1 = new-object system.data.datacolumn "TemplateTitle" $col2 = new-object system.data.datacolumn "TemplateType" $col3 = new-object system.data.datacolumn "FeatureID" $table.columns.add($col1) $table.columns.add($col2) $table.columns.add($col3) ForEach ($item in $list.items) {$row=$table.NewRow();$row.TemplateTitle=$item.Properties.TemplateTitle;$row.TemplateType=$item.Properties.TemplateType;$row.FeatureID=$item.Properties.FeatureID;$table.Rows.Add($row)} $Table | sort-object templateTitle -desc | format-table -auto
References
Notes
  • I've not been able to find the GUID property for default site templates.  It's not listed.  There must be some sort of unique ID for these, since some of them have the same name and must be distinguished by other means.
  • Note that not all custom list template properties are found directly in the item object but that some are found in the Properties sub-object.  Also, because it's a list, you can't easily extract the templates using a single command.  So, instead, I created a table object, populated the table, and then displayed the object using convenient format commands.

No comments: