将模板应用于sharepoint在线站点

时间:2018-05-17 12:04:13

标签: sharepoint-online

我使用PnP方法获取发布网站模板并创建新的网站集并应用模板以便获取源网站的副本。

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

1 个答案:

答案 0 :(得分:0)

变量 $ 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