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

Is it possible to use SharePoint object model to enumerate all sites in an application to determine what the base site definition is? (and also to know if the site was provisioned from a template?) thx

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You can iterate your site collections and examine every SPWeb to discover WebTemplate, WebTemplateId and Configuration.

These values match the template and configuration used to create the site (aka web in API). You can then compare that against the site definitions found in SharePoint root (14 hive if u wish) in the respective ONET.XML files and webtemp*.xml files.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb_members.aspx

In SP2007 there was no way to discover if your site was provisioned by a site definition template or a template file (STP). Since STP files are now retired (for site templates anyway) in favor of WSP files, I would assume that its still impossible to see this.

share|improve this answer

To add to Anders answer, you can get the name through the API, too in 2010 and 2013.

Use SPWeb.GetAvailableWebTemplates. Another SharePoint.stackexchange.com thread has a great example of using the API through PowerShell.

share|improve this answer

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.