首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >上传网站模板wsp文件powershell

上传网站模板wsp文件powershell
EN

Stack Overflow用户
提问于 2014-08-12 21:24:20
回答 2查看 2.3K关注 0票数 1

我正在使用SharePoint 2013,我想从一个网站模板创建一些spweb…

我已经创建了一个站点并添加了所需的内容,然后将该站点另存为模板,然后转到解决方案库并下载了.wsp文件。

现在,我需要用一些基于该模板的子网站创建一个新的网站集合,为此,我认为需要将.wsp文件上传到解决方案库中,这样我才能找到新保存的模板,并且我需要从PowerShell中这样做!

我试了两种方法,

第一,

我尝试添加-spsolution并安装-spsolution,如下所示

代码语言:javascript
复制
Add-SPSolution -LiteralPath $SPIntranetTemplateFilePath
Install-SPSolution -Identity SPITemplateFile.wsp -CompatibilityLevel 15 -force

但是我在解决方案库中找不到.wsp,模板也不在模板列表中……

我尝试使用Install-SPWebTemplate,但此命令在我的PowerShell中未被识别为cmdlet (我添加了Add-PSSnapin Microsoft.SharePoint.PowerShell)

我也用过这个

代码语言:javascript
复制
## SharePoint DLL 
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 

有没有人可以帮助我使用WspFile,就像我可以根据模板创建子网站一样?

EN

回答 2

Stack Overflow用户

发布于 2014-08-13 08:33:57

Add-SPSolution之后尝试Install-SPSolution

http://technet.microsoft.com/en-us/library/ff607534(v=office.15).aspx

票数 0
EN

Stack Overflow用户

发布于 2017-01-26 06:39:53

我认为您需要将其添加为沙箱用户解决方案,以使其显示在站点集合的解决方案库中。这种方法对我很有效。

代码语言:javascript
复制
$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

一旦安装了沙箱解决方案,使用它创建子站点的诀窍就是使用对象模型来获取模板。

代码语言:javascript
复制
$localeId = 1033 # or whatever is appropriate for you
$customTemplate = $theSite.RootWeb.GetAvailableWebTemplates($localeId) | ? { $_.Title -match "Custom Template Title" } 

现在,您可以创建一个完全不基于模板的子站点,然后应用自定义模板:

代码语言:javascript
复制
$newSubsite = $New-SPWeb "http://server/pathto/site/subsite" # can also apply options for unique permissions, nav bar, etc.
$newSubsite.ApplyWebTemplate($customTemplate)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25265458

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档