Wednesday, April 15, 2015

SharePoint 2013: how to view default list and site templates


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 "MyTable" $col1 = new-object "TemplateTitle" $col2 = new-object "TemplateType" $col3 = new-object "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
  • 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: