I want to set "subsites can only use the following site templates" radio button true in settings > Page Layout and Site Templates how to do this process in powershell?
1 Answer
Try this script
$templateNamesToKeep = "STS#0","PROJECTSITE#0","BLOG#0"
Start-SPAssignment -Global
$web = Get-SPWeb <URL of site>
# get the existing web templates from the site that will be filtered down
# 1033 is the locale id for English US (en-us), be sure to change to your locale
$existingWebTemplates = $web.GetAvailableWebTemplates(1033)
$newWebTemplates = New-Object "System.Collections.ObjectModel.Collection[Microsoft.SharePoint.SPWebTemplate]"
# filter existing web templates and only keep if in the list of template names to keep
$newWebTemplates = $existingWebTemplates | Where-Object {$_.name -in $templateNamesToKeep}
$web.SetAvailableWebTemplates($newWebTemplates, 1033)
$web.Update()
Stop-SPAssignment -Global
at $templateNamesToKeep define the template that you need to only use for subsites.
For more details check Set PageLayouts and Site Templates Settings in SharePoint 2013 using PowerShell
-
When I added custom template to the $templateNamesToKeep Its not working. custom site template look like "CustomTemplate#CA18553C-D520-4E1D-8FD4-E57CCF24AA36"Jeeva Jeyapaul– Jeeva Jeyapaul2016-11-18 06:00:29 +00:00Commented Nov 18, 2016 at 6:00
-
are you sure it's the custom template it should like "{YOUR GUID}#TemplateName"2016-11-18 15:59:20 +00:00Commented Nov 18, 2016 at 15:59
-
Oh .. Sorry I Interchanged that thingJeeva Jeyapaul– Jeeva Jeyapaul2016-11-18 16:20:06 +00:00Commented Nov 18, 2016 at 16:20
-
Please try this and tell me the result :)2016-11-18 16:26:26 +00:00Commented Nov 18, 2016 at 16:26