Connect-PnPOnline: The user or administrator has not consented to use the application with ID name ‘PnP Management Shell’

While working with a customer and testing the configuration in my own tenant. I ran in the following error;

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.

Trace ID: b2cf58ed-9797-4f25-863e-a946d8fc2e00

Correlation ID: 1fa13b31-284c-4f43-972a-a2e840dc77e6

Timestamp: 2021-03-08 09:56:01Z

At line:240 char:1

+ Connect-PnPOnline $SpSiteUrl -Credentials $SpCreds

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Connect-PnPOnline], MsalUiRequiredException

    + FullyQualifiedErrorId : 

Microsoft.Identity.Client.MsalUiRequiredException,PnP.PowerShell.Commands.Base.ConnectOnline

 

Add-PnPListItem : There is currently no connection yet. Use Connect-PnPOnline to connect.

At line:242 char:1

+ Add-PnPListItem -List $SpListName -Values @{"Title"=$Inc.Title;"Statu ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Add-PnPListItem], InvalidOperationException

    + FullyQualifiedErrorId : System.InvalidOperationException,PnP.PowerShell.Commands.Lists.AddListItem

 
In order to resolve this issue, I had to run the following PowerShell cmdlets.
$cred = (Get-Credential)

Connect-AzureAD -Credential $cred

Register-PnPManagementShellAccess -SiteUrl https://skypme.sharepoint.com/sites

Scroll down and press Accept.

This resolved my error and I was able to continue with my testing.

Regards
The Author – Blogabout.Cloud

Leave a Reply

Your email address will not be published. Required fields are marked *