Get sharepoint site template PowerShell + (SharePoint Object Model)

In this SharePoint tutorial we will discuss, how to get SharePoint site template using PowerShell. Also, we will discuss how to get SharePoint site templates programmatically using SharePoint server object model.

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.

get sharepoint site template PowerShell

We ca run the below PowerShell command to get SharePoint site template powershell 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
get sharepoint site template powershell
get sharepoint site template powershell

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

We can also use SharePoint 2016/2013 server object model to get 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:

get sharepoint online site template powershell
get sharepoint online site template powershell

You may like following SharePoint Online site template tutorials:

Hope this SharePoint tutorial helps to get sharepoint online site template 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.

>