In my PowerShell script, I want to get the SPWebTemplate which has been used to create a SPWeb. In SPWeb instances, properties WebTemplate and WebTemplateId are accessible, but both of them dont identify a SPWebTemplate uniquely.

For example, if the SPWebTemplate "STS#0" has been used to create a SPWeb, WebTemplate would contain "STS" and WebTemplateId be "1".

Now

Get-SPWebTemplate | where { $_.ID -eq 1 }

would result in 3 results for each installed language (STS#0, STS#1, STS#2). How can I retrieve the correct SPWebTemplate-Name (STS#1)?

Thanks in advance,
Jonas

有帮助吗?

解决方案

Try SPWeb.Configuration.

This property has to be in the running for Most Poorly Named Property - SharePoint API. I remember trying to use WebTemplateId myself until I found Configuration (and I don't remember how I eventually found it).

其他提示

You can try

$web = Get-SPWeb http://site/subsite
Get-SPWebTemplate | where {$_.name -like $web.WebTemplate+"*" } | where {$_.name -like "*"+$web.Configuration }
$web.Dispose()

But keep in mind that some $web.Configuration can be -1.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top