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
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– BrishalApr 15, 2014 at 7:15
-
You can use
Get-SPWebTeamplate
, e.g.,Get-SPWebTemplate | ? { $_.Name -like "*SAHREDSERVICEPROJECT*" }
– eirikbApr 15, 2014 at 7:20 -
3Alternatively, 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
Jun 29, 2015 at 0:56
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.– KCRyanOct 29, 2020 at 15:21
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()