Fix “Connect-PnPOnline : AADSTS65001: 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.”
Problem: When trying to connect to SharePoint Online using PnP PowerShell user name and password, I got this error message: Connect-PnPOnline : AADSTS65001: 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.
#Set Variables
$SiteURL = "https://Crescent.sharepoint.com/"
#Get Credentials to connect
$Cred = Get-Credential
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials $Cred
Solution:
The new PnP.PowerShell module uses an App “PnP Management Shell” with the ID “31359c7f-bd7e-475c-86db-fdb8c937548e” to connect to SharePoint Online, and you must grant permission to this PnP Management Shell application if you want to connect with user name and password.
Run the Register-PnPManagementShellAccess PowerShell cmdlet as a Global Administrator.
Register-PnPManagementShellAccess
You’ll be prompted to consent to a set of permissions. “Consent on behalf of your organization” and click on the “Accept” button.
That’s all. This will resolve the error. As a side note, The Connect-PnPonline -url “site URL” -interactive method just works fine without this step. My post on installing PnP PowerShell for SharePoint Online: How to Install the PnP PowerShell Module for SharePoint Online?
Can i use something like this for an clientid in linke appinv.aspx
I wonder why such permissions as write permission(on catalog? on groups ), invite external guests to organization and acces azure service managment are necesary just to execute some powershell scripts… except for some admin applications maybe, but not in general ..
What if I am not a global admin?
If you are not a global admin, use: Register-PnPManagementShellAccess -ShowConsentUrl and share the URL you get from this cmdlet with the Tenant Admin, and they can complete this consent step from the URL you share.
More here: How to Install the PnP PowerShell Module for SharePoint Online?
Great article.