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

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

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.


New to Office 365 SharePoint Online? Get Office 365 Enterprise E3 Subscription & Try out all the features

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.

Check out Best Alternative to InfoPath -> Try Now

FREE SHAREPOINT 2019 PDF

(Installation & Features)



About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →