Get-Spwebtemplate не показывает мой шаблон, хотя он должен
-
10-12-2019 - |
Вопрос
У меня есть проблема, в основном я установил веб-шаблон, и он был установлен нормально.Когда я пытаюсь создать веб-сайт, я вижу этот шаблон в списке, и я могу выбрать его и на основе этого шаблона создать сайт.
Но странно ценится, это, возможно, не зарегистрировано, или я не знаю почему, но когда я бегу команду PowerShell Get-Spwebtemplate, это не там.Я также могу найти его в улите в SiteTemplate ...
Я чистил кеш и сделал Iisreset, но все же это не там, хотя это работает, как я это исправить?
Решение
Your webtemplate is probably not globally deployed
[..]the documentation for Get-SPWebTemplate which states “Displays all globally installed site templates that match the given identity.” A sandboxed solution is not globally deployed, which explains why the template couldn’t be found. Source
Try this:
$web = get-spweb http://intranet
$template = $web.GetAvailableWebTemplates(1033) | Where-Object {$_.Name -eq "My Custom Template Name"}
#Uncomment to create web..
#New-SPWeb -Url "http://intranet/site1" -Name "Site 1" –Template $template
This will get it from available web templates instead, see more (and source of above script) here
Другие советы
After trying to figure this out myself, I got the following that is dynamic. Hope this helps someone else that needs to use a template in multiple places.
$Siteurl = "http://intranet/site/custom"
$SPW = Get-SPweb $Siteurl
$template = $SPW.GetAvailableWebTemplates(1033) | Where-Object {$_.Title -eq "MyCustomTemplate"}
write-host "Applying custom template..."
$SPW.ApplyWebTemplate($template.Name)
$SPW.update()
Perhaps you may need to restart the server. I recently had a similar issue. However, I was migrating from SP 2010 to SP 2013. See here for more info: http://sharepointnadeem.blogspot.com/2014/01/sharepoint-2013-missingsitedefinition.html