Blog链接:​https://blog.51cto.com/13969817

今天小伙伴使用PnP Powershell连接SharePoint Online时,遇到如下错误:

ADSTS65001: The user or administrator has not consented to use the application with ID ‘31359c7f-bd7e-475c-86db-fdb8c937548e’ named ‘PnP Management Shell’. Send an interactive authorization request for this user and resource.

Microsoft 365 开发:使用PnP Powershell连接SharePoint Online失败_SharePoint Online

解决方案:新的PnP.PowerShell模块使用ID为“31359c7f-bd7e-475c-86db-fdb8c937548e”的应用程序“PnP Management Shell”连接到SharePoint Online,如果要使用用户名和密码连接必须授予此PnP Management Shell应用程序权限。

具体操作步骤如下所示:

1.      以Global Administrator来执行Register-PnPManagementShellAccess,然后弹出的窗口中,勾选“Consent on behalf of your organization,点击Accept,如下所示:

Microsoft 365 开发:使用PnP Powershell连接SharePoint Online失败_SharePoint Online_02

2.      输入如下命令,就可以成功连接了。

$SiteURL= "https://Crescent.sharepoint.com/"  

$Cred= Get-Credential

Connect-PnPOnline-Url $SiteURL -Credentials $Cred


总结本文,希望给小伙伴提供排错方法,谢谢大家阅读。