【问题标题】:upload site template wsp file powershell上传网站模板wsp文件powershell
【发布时间】:2014-10-05 14:10:44
【问题描述】:

我正在使用 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,就像我可以根据我的模板创建子网站一样?

【问题讨论】:

    标签: powershell sharepoint-2013 wsp sitetemplate


    【解决方案1】:

    Add-SPSolution 之后尝试Install-SPSolution

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

    【讨论】:

    • 如我的帖子中所述...这是我尝试过的,但它不起作用,因为 template.wsp 不在解决方案库中,也没有出现在自定义模板列表中
    【解决方案2】:

    我认为您需要将其添加为沙盒用户解决方案,以便它显示在网站集的解决方案库中。这种方法对我有用。

    $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" } 
    

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

    $newSubsite = $New-SPWeb "http://server/pathto/site/subsite" # can also apply options for unique permissions, nav bar, etc.
    $newSubsite.ApplyWebTemplate($customTemplate)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-06
      • 1970-01-01
      • 2014-02-19
      • 1970-01-01
      • 1970-01-01
      • 2021-07-05
      相关资源
      最近更新 更多