9

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?

17

You mean like this?

$web = Get-SPWeb http:/SC/site
$web.WebTemplate + " " + $web.WebTemplateId
$web.close()
  • 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 – Brishal Apr 15 '14 at 7:15
  • You can use Get-SPWebTeamplate, e.g., Get-SPWebTemplate | ? { $_.Name -like "*SAHREDSERVICEPROJECT*" } – eirikb Apr 15 '14 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 – Underverse Jun 29 '15 at 0:56
1

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.

0

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()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.