首页 > 解决方案 > 将模板应用到共享点在线站点

问题描述

我正在使用 PnP 方法获取发布站点模板并创建新站点集合并应用模板,以便获得源站点的副本。

我收到错误 - 运行以下 powershell 脚本以应用模板时,模板的范围与目标不匹配 - $web="https://shareptdev.sharepoint.com/sites/newpub/replicasite $templateFile = "E:\ Path\template.xml"; Apply-PnPProvisioningTemplate -Web $web -Path $templateFile

标签: sharepoint-online

解决方案


变量$web必须是您的站点上下文,必须在连接的站点上使用Get-PnPWeb 。像这样的东西:

$siteUrl = "https://shareptdev.sharepoint.com/sites/newpub/replicasite"
Connect-PnPOnline -Url $siteUrl -UseWebLogin
$web = Get-PnPWeb

$templateFile = "E:\Path\template.xml"
Apply-PnPProvisioningTemplate -Web $web -Path $templateFile

推荐阅读