How to Hide Site Templates in SharePoint with PowerShell?

How to hide a site template in SharePoint ? Editing “webtemp.xml” file is one option to hide site templates in SharePoint 2007 as per my another article: Hide Site templates & List Templates in SharePoint

However, There is an another way to hide site templates in SharePoint 2010: Using PowerShell! Update “WebTemplates” property of SPWeb object. Say for E.g. The below script sets available web templates to “Team sites” and “Blog”. All others will be removed!

$Web = Get-SPWeb "https://sharepoint.crescent.com/teams/"

$Web.AllProperties["__WebTemplates"] = "<webtemplates><lcid id=""all""><webtemplate name=""STS#0"" /><webtemplate name=""BLOG#0"" /></lcid></webtemplates>"

#To Reset to Default, Use: $Web.AllowAllWebTemplates()

$Web.Update()

Just supply the site template ids to the above code to make it available. You can hide custom site templates as well. To get all available site templates, use: Get-SPWebTemplate SharePoint Site Template IDs Reference

Here is the Before and After screens:
hide site templates sharepoint
After Executing the Script:

hide site template sharepoint

Hiding SharePoint site template can be achieved using C# Object model also. Manipulate SPWebTemplateCollection of SPWeb object and update it to hide a site template in SharePoint 2010 or in SharePoint 2007.

Remove Web Templates from SharePoint 2016 using PowerShell:

For SharePoint 2013 and SharePoint 2016, you can limit available site templates from site settings. Here is how:

  • Go to Site Settings >> Click on “Page Layout and Site Template Settings”
  • Set the option “Subsites can only use the following site templates” and Add templates to the right side list. 
    hide site templates in sharepoint 2016

PowerShell to hide web template in SharePoint 2013:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$SiteURL="https://intranet.crescent.com"

$Web = Get-SPWeb $SiteURL

#Get all web templates from the site
$WebTemplateCollection = $web.GetAvailableWebTemplates(1033)

#Get Team site and Blog site templates
$NewTemplateCollection = $WebTemplateCollection | where {$_.Name -eq "STS#0" -or $_.Name -eq "BLOG#0"}

#Update available web templates
$web.SetAvailableWebTemplates($NewTemplateCollection, 1033)
$web.Update()

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

2 thoughts on “How to Hide Site Templates in SharePoint with PowerShell?

  • where i have to execute this code??

    As java SCRIPT or when?? please guide me on this. Thanks

    Reply
    • Its a PowerShell Script! Execute it using SharePoint PowerShell Management Shell or PowerShell ISE from your WFE.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *