Hide specific Site Template from SP2010 Site creation list using Powershell or Stsadm
-
10-12-2019 - |
Question
I have some custom site templates.. Now i want to just hide those templates from the Site Creation List..
I found some ways to like editing webtemp.xml and doing it from UI for each site collection.. editing webtemp.xml is not fair because im doing this on production environment and Doing it from the UI also not a solution..
But because im doing production deployment i want script to do this.. I just want code snippert to hide those custom templates..
And i want to say that disabling Templates won't meet my requirements.. because it will ruined my created sites from those templates..
Solution
We can hide the site templates using powershell, the below powershell script will remove all the templates other than "Team sites" and "Blog".
$Web = Get-SPWeb "http://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()
You can hide custom site templates as well, just by passing the template ID's in the above code.
SharePoint Site Template IDs Reference
We can also hide the site templates programmatically, use the below link to do it programmatically.
Hiding SharePoint 2010 web templates programmatically
NOTE:
Please test the above powershell code in your test environment and then use it in production environment.
Hope this helps you.