【问题标题】:PowerShell, SharePoint: Get-PnPSiteTemplate ErrorPowerShell、SharePoint:获取 PnPSiteTemplate 错误
【发布时间】:2021-11-01 13:46:56
【问题描述】:

我在使用 PnP PowerShell cmdlet 时遇到错误:Get-PnPSiteTemplate。我也是全局管理员和网站集管理员。

自定义脚本已启用:

set-sposite https://tenant.sharepoint.com/sites/TestSite -denyaddandcustomizepages $false

Connect-PnPOnline -Url https://tenant.sharepoint.com/sites/TestSite -Interactive

Get-PnPSiteTemplate -Out "C:TempDemo.xml"

Get-PnPSiteTemplate : Attempted to perform an unauthorized operation.
At C:\Users\userX\Desktop\Script.ps1:3 char:1
+ Get-PnPSiteTemplate -Out "C:TempDemo.xml"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Get-PnPSiteTemplate], ServerUnauthorizedAccessException
    + FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Provisioning.Site.GetSiteTemplate

有人有想法吗? MS 说 PnP 是开源的,所以没有真正的支持...

目标是将包含所有项目和元数据的完整 SharePoint 列表复制到另一个网站。像这样: https://www.drware.com/copy-a-list-with-list-items-to-another-site/

谢谢! :)

【问题讨论】:

  • 您是否检查过,您登录时使用的用户对该站点具有完全权限?即使用户是全局管理员,这一点也很重要。

标签: powershell sharepoint


【解决方案1】:

我在一个干净的通信站点上使用最新版本的 PnP.PowerShell(版本 1.7.0)重新检查了该命令,其中包含几个项目的示例列表,仅此而已,并且可以正常工作?。

  1. 您是否也可以先使用一个自定义列表在某个测试干净的站点上重试,看看是否有相同的错误?也许您遇到的问题与您在此站点上的某些自定义有关,因为没有任何参数的 Get-PnPSiteTemplate 将导出整个站点的模板(包括列表,还有所有其他内容,例如您可能不使用的一些自定义应用程序'无权做)

  2. 您可以尝试的另一件事是运行 cmdlet 以仅检索您感兴趣的列表以及数据:

# this will export the template only of the selected list
Get-PnPSiteTemplate -Out "C:\TempDemo.xml" -ListsToExtract "testList" -Handlers Lists -Force

# this will populate the list with data of the list
Add-PnPDataRowsToSiteTemplate -Path "C:\TempDemo.xml" -List "testList"

【讨论】:

    猜你喜欢
    • 2018-11-18
    • 2020-09-17
    • 2018-04-06
    • 2017-11-01
    • 2018-01-02
    • 1970-01-01
    • 1970-01-01
    • 2021-12-26
    • 1970-01-01
    相关资源
    最近更新 更多