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?

Robert Lindgren
  • 24,520
  • 12
  • 53
  • 79
Brishal
  • 1,205
  • 11
  • 42
  • 59

3 Answers3

18

You mean like this?

$web = Get-SPWeb http:/SC/site
$web.WebTemplate + " " + $web.WebTemplateId
$web.close()
eirikb
  • 7,405
  • 5
  • 35
  • 67
  • 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 07:15
  • You can use Get-SPWebTeamplate, e.g., Get-SPWebTemplate | ? { $_.Name -like "*SAHREDSERVICEPROJECT*" } – eirikb Apr 15 '14 at 07: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 00: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.

  • 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. – KCRyan Oct 29 '20 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()
Ganesha
  • 256
  • 1
  • 8