Fix Connect-PnPOnline: AADSTS65001 Error

When you try to connect to SharePoint Online using Connect-PnPOnline cmdlet, you may have encountered the following 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.
Trace ID: c6548a52-81bf-4d6d-bf7e-68bb179b6700
Correlation ID: 6f4ad9fb-531a-40cc-ac20-5da83021e3cf
Timestamp: 2021-12-21 13:17:34Z
At line:1 char:1
Connect-PnPOnline -Url https://techpress-admin.sharepoint.com/
~~~~~~~~~~~~~ CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], MsalUiRequiredException
FullyQualifiedErrorId : Microsoft.Identity.Client.MsalUiRequiredException,PnP.PowerShell.Commands.Base.ConnectOnline

Connect-PnPOnline Error

Below is the screenshot of the error message while trying to establish a connection with SharePoint Online using the following command:

Connect-PnPOnline -Url https://techpress-admin.sharepoint.com/

Fix for Connect-PnPOnline AADSTS65001 Error

As of September 9, 2024, App registration for PnP PowerShell c6548a52-81bf-4d6d-bf7e-68bb179b6700 has been deleted. There are new changes introduced in PnP PowerShell on how it can be used to connect to Microsoft 365.

As this app no longer exists, If you try to use Register-PnPManagementShellAccess cmdlet to request for admin consent, you will first get below error on the console.

WARNING: This cmdlet will provide consent for the PnP Management Shell Entra ID multi-tenant app. It is strongly recommended to register your own app in your Entra ID and use that for authentication instead. See the documentation for Register-PnPEntraIDApp.

Register-PnPManagementShellAccess Error

After entering admin user credentials, you will get the below error message:

AADSTS700016: Application with identifier ‘31359c7f-bd7e-475c-86db-fdb8c937548e’ was not found in the directory ‘Cloudinfra.net’. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant.

AADSTS700016 Error

AADSTS700016 Error when using Register-PnPManagementShellAccess

To fix this Issue and establish a connection with SharePoint Online using Connect-PnPOnline cmdlet successfully, you need to create an app registration in Entra ID.

In the following guide, I have detailed the steps to create Microsoft 365 groups using PowerShell. I have also showed on connecting to connect with SharePoint online using Connect-PnPOnline with the help of Entra App and a Self-signed certificate.

#Connecting with SharePoint Online using PnP PowerShell

Read Next

Leave a Comment