我正在使用SharePoint 2013,我想从一个网站模板创建一些spweb…
我已经创建了一个站点并添加了所需的内容,然后将该站点另存为模板,然后转到解决方案库并下载了.wsp文件。
现在,我需要用一些基于该模板的子网站创建一个新的网站集合,为此,我认为需要将.wsp文件上传到解决方案库中,这样我才能找到新保存的模板,并且我需要从PowerShell中这样做!
我试了两种方法,
第一,
我尝试添加-spsolution并安装-spsolution,如下所示
Add-SPSolution -LiteralPath $SPIntranetTemplateFilePath
Install-SPSolution -Identity SPITemplateFile.wsp -CompatibilityLevel 15 -force但是我在解决方案库中找不到.wsp,模板也不在模板列表中……
我尝试使用Install-SPWebTemplate,但此命令在我的PowerShell中未被识别为cmdlet (我添加了Add-PSSnapin Microsoft.SharePoint.PowerShell)
我也用过这个
## SharePoint DLL
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 有没有人可以帮助我使用WspFile,就像我可以根据模板创建子网站一样?
发布于 2014-08-13 08:33:57
在Add-SPSolution之后尝试Install-SPSolution
http://technet.microsoft.com/en-us/library/ff607534(v=office.15).aspx
发布于 2017-01-26 06:39:53
我认为您需要将其添加为沙箱用户解决方案,以使其显示在站点集合的解决方案库中。这种方法对我很有效。
$theSite = Get-SPSite "http://server/pathto/site"
# add the solution to the sandbox
Add-SPUserSolution (Resolve-Path .\relativePathTo.wsp) -Site $theSite
# get the user solution and activate it for the site
$customSolution = Get-SPUserSolution -Site $theSite | ? { $_.Title -match "Custom Template Title" }
Install-SPUserSolution $customSolution -Site $theSite一旦安装了沙箱解决方案,使用它创建子站点的诀窍就是使用对象模型来获取模板。
$localeId = 1033 # or whatever is appropriate for you
$customTemplate = $theSite.RootWeb.GetAvailableWebTemplates($localeId) | ? { $_.Title -match "Custom Template Title" } 现在,您可以创建一个完全不基于模板的子站点,然后应用自定义模板:
$newSubsite = $New-SPWeb "http://server/pathto/site/subsite" # can also apply options for unique permissions, nav bar, etc.
$newSubsite.ApplyWebTemplate($customTemplate)https://stackoverflow.com/questions/25265458
复制相似问题