SharePoint Dragons

Nikander & Margriet on SharePoint

Can’t use PowerShell to create a site using a site template

Just stumbled across this. It’s not possible to use PowerShell to create a site based on a site template.

In this example, we’ve created a site template called “mytemplate” based on the “STS” template. Normally, you can use the new-spweb cmdlet and specify a template like so:

new-spweb http://moon/sites/sc1/autosite1 -template “mytemplate”

(Or add –whatif to the end if you’re getting cold feet).The –tempate parameter accepts a piped spwebtemplate object, which can be retrieved via:

Get-SPWebTemplate | more

As you will see, a site template saved in the site collection solution catalog won’t show up here. As an alternative, you can try to establish the template that was used to create an existing web site, like so (please note, we’ve created a site called “myinstance” using the “mytemplate” site template:

$web = get-spweb http://moon/sites/sc1/myinstance

write-host “Web Template:” $web.WebTemplate ” | Web Template ID:” $web.WebTemplateId

$web.Dispose()

If you experiment with this, you will find that the web template it still the underlying parent of the saved template. In my case “mytemplate” was based on the “STS” template, so that’s still the one that is actually the web template of “myinstance”.

Advertisements

One response to “Can’t use PowerShell to create a site using a site template

  1. Leesa February 17, 2013 at 5:02 pm

    just stopped by to view this website. It seems to be really interesting and I had a good time reading it, thank you very much for the helpful writing!

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: