【问题标题】:Get-PnPProvisioningTemplate Execution error in RunbookRunbook 中的 Get-PnPProvisioningTemplate 执行错误
【发布时间】:2021-07-05 01:18:05
【问题描述】:

我在 Runbook 中运行了以下 Powershell,但出现错误。 如果逻辑中有不恰当的部分,请指出。

补充 当我将名称更改为 Get-PnPFolderItem 而不是 Get-PnPProvisioningTemplate 并执行它时,它工作正常。 所以我认为Connect-PnPOnline是可以正常连接的。

$TempSiteUrl = Get-AutomationVariable -Name 'SiteTemplateUrl'
$myCred = Get-AutomationPSCredential -Name SharePointConnect
Connect-PnPOnline -Url $TempSiteUrl -Credentials $myCred
Get-PnPProvisioningTemplate -Out template.xml

错误信息

Get-PnPProvisioningTemplate : There is currently no connection yet. Use Connect-PnPOnline to connect.
At line:4 char:1
+ Get-PnPProvisioningTemplate -Out template.xml
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-PnPProvisioningTemplate], InvalidOperationException
    + FullyQualifiedErrorId : 
System.InvalidOperationException,PnP.PowerShell.Commands.Provisioning.Site.GetProvisioningTemplate

【问题讨论】:

    标签: powershell sharepoint-online azure-automation runbook microsoft365


    【解决方案1】:

    【讨论】:

    • 感谢您的回答。我使用 Get-PnPSiteTemplate 而不是 Get-PnPProvisioningTemplate 运行它,并且能够成功连接到 SharePoint 站点并获取模板。太感谢了!!!顺便问一下,Get-PnPProvisioningTemplate 和 Get-PnPSiteTemplate 有什么区别吗?我很惊讶它停止工作,因为 Get-PnPProvisioningTemplate 在今年 3 月之前一直正常工作。
    • 以前是Get-PnPProvisioningTemplate。在新版本的 PNP powershell 中,Get-PnPProvisioningTemplate 已被 Get-PnPSiteTemplate 取代。
    • 非常感谢您告诉我!这对我帮助很大!
    • 不客气:) 此外,Apply-PnPProvisioningTemplate 已被 Invoke-PnPSiteTemplate 取代。我想这对你也有帮助。
    • 谢谢!!这正是我所做的,使用 Apply-PnPProvisioningTemplate 来应用模板!当我将其更改为 Invoke-PnPSiteTemplate 并运行它时,我能够成功应用模板。顺便说一句,应用模板后,站点的站点导航中会显示“最近使用的项目”。你知道如何防止在应用模板时出现这种情况吗?
    猜你喜欢
    • 1970-01-01
    • 2018-03-07
    • 2021-05-27
    • 1970-01-01
    • 1970-01-01
    • 2016-08-05
    • 2018-01-09
    • 1970-01-01
    • 2017-05-04
    相关资源
    最近更新 更多