Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created a custom site definition which I can see and create a site using my custom definition with the UI. However, if I try to create a site using powershell I get an error saying WARNING: Template is not found and is not applied.

I have verified that the Template param for New-SPWeb matches the definition name and configuration Id TestDefinition#0.

I looked at the available web templates using the command Get-SPWebTemplate and my new site definition is not showing up is not available in the collection. I do see other definitions created previously but not my new one.

Anyone have any ideas why I can't create a site this way?

share|improve this question
add comment

1 Answer 1

This is a bit tricky, I must say. If you use Get-SPWebTemplate, I think you only get the built-in templates. If you want to find a custom site-template, you have to dance a little...

Here is what I have used, supplying the GUID along with name of the custom Site Template. Notice my $sitetemplatename - that last hash is part of the name; it isn't a comment. You put the GUID + # + name all together, just like that.

#You need to fish this out of SCA.  After you have saved the site template (with content), use the ps command in BGM's profile: listwebtemplates
$sitetemplateName = "{4755D494-88F9-4F59-909E-875F6D518A56}#MySiteTemplateName"

New-SPWeb -Url $SiteUrl -Name $SiteTitle -UniquePermissions:$true -Description $sitedescription
$currentWeb = Get-SPWeb $SiteUrl
write-host "Applying custom template..."
$currentWeb.ApplyWebTemplate($sitetemplateName)
$currentweb.update()
share|improve this answer
    
I think Mark asks for custom site definitions not web templates. Both should show in Get-SPWebTemplates provided the feature containing the templates are enabled. Check that the farm/site scoped feature with the site definition/web template are enabled –  Anders Rask Jan 3 '13 at 11:47
    
Thanks for your comment, Mr. Rask. I'd hate to confuse anyone besides myself! –  BGM Jan 3 '13 at 15:23
    
I'm interested to know if this was resolved. I have the same problem. @Anders Rask ... why would the feature be important? Aren't Site Definitions deployed as part of the package ... not a feature? –  SteveCl Aug 28 '13 at 15:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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