I've got the following problem: There is a solution I didn't develop, that creates and configures a new Website. I have to change the Site Template that is used for this. So I changed the template Website and saved it as a Site Template, but the solution doesn't find the Site Template:

The template seems available on all Websites in the Site Collection except for the one SPWeb where the solution searches for it.

When I call GetAvailableWebTemplates([System.UInt32]1031) on the SPWeb of http://mysitecollection/, I get:

  • all the standard templates
  • the old Site Template
  • my new Site Template

When I call it on the SPWeb of http://mysitecollection/subweb/, I get:

  • only the old Site Template

How do I copy my new Site Template to this Website? Is there a way in the UI or via PowerShell? I tried to call AllowAllWebTemplates() on the Website, but to no avail ...

  • If it's a wsp then you could open the wsp, copy it to the new web and deploy it this can be done. Is it a wsp?
    – Hugh Wood
    Jun 24, 2013 at 12:57
  • It is a wsp, but since the sandbox solutions are stored on the site collection, how should I copy the wsp to another web within the same site collection? Plus: the wsp of the old template is stored in exact this solution store, so the wsp seems to be in the correct place, only the template doesn't appear in the right web ...
    – Hinek
    Jun 24, 2013 at 13:11
  • The code doesn't work with a sandbox solution I feel because you would possibly have to use System.IO... File.ReadAllBytes to get the wsp and put it on the other web app. If you can run it maybe something like this: blogs.technet.com/b/patrick_heyde/archive/2009/08/28/…
    – Hugh Wood
    Jun 24, 2013 at 13:18
  • I really don't know where you going with this ... I could extract the wsp without any tool, using PowerShell ... but I don't want to: The wsp is exactly where it should be. Only the template is not in the right sub web.
    – Hinek
    Jun 24, 2013 at 14:17
  • Okay I misunderstood I thought you wanted to do it programmatically and that tool is a good example of how to do it. I was on the wrong train on the thought...
    – Hugh Wood
    Jun 24, 2013 at 14:24

1 Answer 1


Ok, I found out:

$templateTitle = "MySiteTemplate"
$srcWeb = Get-SPWeb http://mysitecollection
$destWeb = Get-SPWeb http://mysitecollection/subweb

$template = $srcWeb.GetAvailableWebTemplates(1031) | where { $_.Title -eq $templateTitle }
$collection = New-Object 'System.Collections.ObjectModel.Collection[Microsoft.SharePoint.SPWebTemplate]'

$destWeb.SetAvailableWebTemplates($collection, 1031)

  • Note that this will most likely clear away the existing web templates. To fix this initially re-add the existing templates from $destWeb before adding $template ($destWeb.GetAvailableWebTemplates(1031) | % { $colletion.Add($_) })
    – eirikb
    Mar 5, 2015 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.