views:

611

answers:

2

I'm trying to script the creation of sites for the fab 40 Microsoft SharePoint templates. I'm having trouble finding the value for the sitetemplate parameter for the stsadm command to create the sites.

e.g.:

stsadm -o createsite -url http://Test/sites/Team_Site **-sitetemplate STS#0** -title "Team Site" ...

Is there a command I can run, or somewhere I can look to find the sitetemplate value for WSP packages (e.g. BugDatabase.wsp)?

+1  A: 

I think the easiest way to do this is via PowerShell, but you can write code to do the same thing. The key is to get a reference to the web and then call SPWeb.GetAvailableWebTemplates(lcid).

Here's a few lines of PowerShell script/command to spit the Name and Title properties out on the screen:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")  
$theSiteColl = New-Object Microsoft.SharePoint.SPSite("http://server")  
$theWeb = $theSiteColl.OpenWeb()  
$theWeb.GetAvailableWebTemplates(1033) | select name, title  
#put your locale ID in the function call

The Name column is the one you have to pass into the stsadm -o createsite command, and the Title column helps associate it with something that makes sense. On my test box, the BugDatabase application template is BT#0.

Abs
Awesome. That's exactly what I was looking for. Thanks!
Jim
A: 

A WSP is just a CAB file that can contain multiple templates. I think you'd need to do this manually. To do this, rename the WSP to have a cab extension, extract the manifest.xml and webtemp* files from the WSP, and look there. A site definition's programatic name is just the name of the site definition, followed by #, and then the configuration ID. For instance, to create a site using configuration 0 of the STS template, you would use STS#0.

Yuliy
That would work for site definitions, but not site templates. When site templates are globally deployed, they are assigned a somewhat random name, such as _GLOBAL_#5.
Jim