Powershell: Update “Subsite Templates” under AreaTemplateSettings.aspx


This time I am discussing about how one can update the “AvailableWebTemplates” once you have created a site. Just for the information, we can define this property in Onet.xml while creating any new site. But what if you have created sites, sub sites underneath and sub sub sites underneath, in that case you need a power shell script to update all those values.

Background: This property is defined in Onet as shown below:

<Feature ID=”22A9EF51-737B-4ff2-9346-694633FE4416″>


<Property Key=”AvailableWebTemplates” Value=”*-CMSPUBLISHING#0;*-BLANKINTERNET#2;*-ENTERWIKI#0;*-SRCHCEN#0″/>



But once site is created using this site template, we have to dig down to update this. Using power shell its quite easy task provided you must know the Id and template name.

Work Arround:

We using the below mention code we can override the web template property. In order to update that we must know the name of template which we want to update its like CMSPUBLISHING#0 ,it follows the rule of <template name>#<configuration id>. How to get the web template

So after that run the following code in power shell:

$url = ‘http://sgtspweb01/&#8217;

$SPSite = Get-SPSite -Identity $url

foreach ($SPWeb in $SPSite.AllWebs)
$SPWeb.AllProperties[“__WebTemplates”] = ‘<webtemplates><lcid id=”all”><webtemplate name=”CMSPUBLISHING#1″ /><webtemplate name=”CMSPUBLISHING#0″ /></lcid></webtemplates>’

write-host “Template ‘” $templateName “‘succesfuly added to web on ” $SPWeb.Url

Notice that “__WebTemplates” property stores the value in the xml template, so sometimes you have to just add one template then you must get the existing value of the property first then update it with the desired one.

Some times you may need to know the site template of the existing site. The code to get the title and Id of web template for any site is as follows:

$web = Get-SPWeb http://portal
write-host “Web Template:” $web.WebTemplate ” | Web Template ID:” $web.WebTemplateId

Hope that helped you.

Happy SharePointing :)…

Published by Mohit Vashishtha

Having extensive experience in software industry as a Team Lead and SharePoint consultant. I have worked with various MS technologies like SharePoint, .Net, AngularJS and Angular 6. I love to learn and share new things which I learn during my experience.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: