Friday, June 22, 2007

File or arguments not valid for site template

I was trying to use stsadm to create a SharePoint 2007 site collection using the createsiteinnewdb operation. I specified the site template name using the -sitetemplate switch but I kept getting the following error:

File or arguments not valid for site template [template name]

Here's the full command I was using:

stsadm -o createsiteinnewdb -url http://someurl/ -sitetemplate "publishing portal"

Turns out that silly me was supplying the template's display name and not its system name. So in order for the command to work correctly, I should have used "blankinternetcontainer#0" instead of "publishing portal". Where "blankinternetcontainer" is the name of the site definition and "0" is the configuration to be used.

stsadm -o createsiteinnewdb -url http://someurl/ -sitetemplate "blankinternetcontainer#0"

A quick way to get a list of template names is to navigate to the following page :http://website/_layouts/templatepick.aspx. Right-click on the page, view the source and pick out the name of the template from the values of the list items.