I want to create subsite using custom template. how can get list of activated custom template name using powershell script?

3 Answers 3


I have answered for the same kind of query , Please find below the detail to get the available custom templates and create a sub-site based on that .

This can be achieved using power shell and CSOM by following below steps .

Once the custom template is uploaded into the solution gallery of the site collection execute the below commands in Powershell:

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web ServerExtensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web ServerExtensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

$Site = "SiteCollectionURL"
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($Site)

List Custom Templates

$Templates = $Context.Site.GetWebTemplates("1033","0")
$Templates | Where {$_.Name -like "*{*" } | Select Name, Description

This will list out all the custom templates available in the gallery.

And execute the below commands to create the subsite using the custom template:

Create Sub-Web using the Custom Template

$WCI = New-Object Microsoft.SharePoint.Client.WebCreationInformation
$WCI.WebTemplate = "{516EB07D-8711-4B9F-A3AD-097B28C5CDDF}#MyCustomTemplate"
$WCI.Description = "MyNewSubSite"
$WCI.Title = "MyNewSubSite"
$WCI.Url = "MyNewSubSite"
$WCI.Language = "1033"
$SubWeb = $Context.Web.Webs.Add($WCI)
  • when i'm creating subsite using custom template I got this error Exception calling "ExecuteQuery" with "0" argument(s): "The site template requires that the Feature {ce503d26-5ac4-4af9-be10-e167610d7bd1} be installed in the farm or site collection." Nov 17, 2016 at 9:53
  • Please make sure that the solution for the custom template is activated . other thing try to get the feature using get-spfeature -identity {guid} and check the results. Try to enable this feature using Enable-SPFeature -identity "MyCustom" -URL somesite
    – Esaki
    Nov 17, 2016 at 10:07
  • When I run It returns another error ca18553c-d520-4e1d-8fd4-e57ccf24aa36 in scope Local farm. Nov 17, 2016 at 10:18
  • can you post the entire error thrown ??
    – Esaki
    Nov 17, 2016 at 10:22
  • Its not a web template it is a site template Nov 17, 2016 at 10:31

This should help

$web = get-spweb http://intranet
$template = $web.GetAvailableWebTemplates(1033) 

To create a new subsite, based off of a custom web template, you can use the following script

$web = get-spweb http://intranet
$template = $web.GetAvailableWebTemplates(1033) | Where-Object {$_.Name -eq "My Custom Template Name"}
New-SPWeb -Url "http://intranet/site1" -Name "Site 1" –Template $template

Try the below code, will give you a list of all available templates. Using this, you can find out the custom template name as well as its ID

function Get-SPWebTemplateWithId 
     $templates = Get-SPWebTemplate | Sort-Object "Name" 
     $templates | ForEach-Object { 
    $templateValues = @{ 
     "Title" = $_.Title 
     "Name" = $_.Name 
     "ID" = $_.ID 
     "Custom" = $_.Custom 
     "LocaleId" = $_.LocaleId 

New-Object PSObject -Property $templateValues | Select @("Name","Title","LocaleId","Custom","ID") 

Get-SPWebTemplateWithId | Format-Table
  • It shows only default templates Nov 17, 2016 at 6:12

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.