Retrieve all site templates using PowerShell and server object model in SharePoint 2016/2013

This SharePoint tutorial we will discuss, how can we retrieve all site templates using PowerShell and server object model in SharePoint 2013/2016. If you want to retrieve site templates in SharePoint Online, you can check how to retrieve all site templates available in SharePoint Online using PowerShell.

Retrieve Site Templates using PowerShell in SharePoint 2013/2016

We ca run the below PowerShell command to retrieve all site templates in SharePoint 2013/2016 like below:

If you are new to SharePoint PowerShell, then you can read Working with PowerShell in SharePoint Online/2016/2013.

Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
Get-SPWebTemplate

If you want to retrieve in .txt or .csv format then you can write like below:

Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
Get-SPWebTemplate > E:\AllTemplates.txt
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
Get-SPWebTemplate > E:\AllTemplates.csv

 Retrieve all site templates using PowerShell and retrieve site templates using SharePoint 2016 server object model
Retrieve all SharePoint 2016/2013 site templates using PowerShell

Retrieve Site Templates using Server Object Model in SharePoint 2013/2016

We can also use SharePoint 2016/2013 server object model to retrieve all the site templates in SharePoint. Here I am using a windows application to display all site templates in SharePoint 2016/2013.

string s = string.Empty;
using (SPSite site = new SPSite(“http://mypc:29024/sites/SPTraining/”))
{
SPWeb web = site.OpenWeb();
SPWebTemplateCollection Templates = site.GetWebTemplates(1033);
foreach (SPWebTemplate template in Templates)
{
s += “Title: ” + template.Title + ” :: Name:” + template.Name + “\n”;
}
}

label10.Text = s.ToString();

Once we run the code, the templates will appear like below:

Retrieve all site templates using PowerShell and retrieve site templates using SharePoint 2016 server object model
retrieve site templates programmatically using SharePoint 2016 server object model

You may like following SharePoint Online site template tutorials:

Hope this SharePoint tutorial helps to retrieve all site templates using PowerShell and Server Object model in SharePoint 2016/2013.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>