10

I have a site collection http:/SC/ under which I have a site http:/SC/site. Can you provide powershell to check which template http:/SC/site is using?

3 Answers 3

19

You mean like this?

$web = Get-SPWeb http:/SC/site $web.WebTemplate + " " + $web.WebTemplateId $web.close() 
3
  • I got the result "SAHREDSERVICEPROJECT" and template ID can I get my template display name also? or any way to check which template display name has this ID Commented Apr 15, 2014 at 7:15
  • You can use Get-SPWebTeamplate, e.g., Get-SPWebTemplate | ? { $_.Name -like "*SAHREDSERVICEPROJECT*" } Commented Apr 15, 2014 at 7:20
  • 3
    Alternatively, on one line: Get-SPWeb -Site "http://sc" | select Title, URL, WebTemplate, WebTemplateId or, get all webs in a site: Get-SPSite | Get-SPWeb | select Title, URL, WebTemplate, WebTemplateId Commented Jun 29, 2015 at 0:56
2

The accepted answer is only partly correct. If the question was to get the name of the used web template, the correct answer would be:

$web = Get-SPWeb http:/SC/site $web.WebTemplate + "#" + $web.Configuration 

It seems, Microsoft had an issue (or later added requirement) when implementing these templates, because there is a "background"-id ($web.WebTemplateId) which presumably denotes the base template used - and there is a "foreground"-id ($web.Configuration) which is added to the template name, delimited by the # sign.

If you use Get-SPWebTemplate, you can see that all the three STS Templates have the same "background"-id but different "foreground"-ids in their name:

PS C:\WINDOWS\system32> Get-SPWebTemplate -Identity "STS#0" | Select-Object Name,Id Name ID ---- -- STS#0 1 PS C:\WINDOWS\system32> Get-SPWebTemplate -Identity "STS#1" | Select-Object Name,Id Name ID ---- -- STS#1 1 PS C:\WINDOWS\system32> Get-SPWebTemplate -Identity "STS#2" | Select-Object Name,Id Name ID ---- -- STS#2 1 

For Webs of all three types, using $web.WebTemplateId will always be 1 ("background"-id) and the value in $web.Configuration will vary according to the template and be 0, 1 or 2 ("foreground"-id).

So, to get the name of the used template, the correct field for the template number would be $web.Configuration, not $web.WebTemplateId.

1
  • This is correct. If you view source and search for g_wsaSiteTemplateId, the result is the same as the PowerShell above. Otherwise, you will always get #STS1. Commented Oct 29, 2020 at 15:21
1

PowerShell code to find the site template id and name

$web = Get-SPWeb http://dmsApp/dept/ceo/ write-host "Web Template:" $web.WebTemplate " | Web Template ID:" $web.WebTemplateId $web.Dispose() 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.