Cannot register PnP.Powershell - Authentication Failed

Nathan Metzler 1 Reputation point
2022-12-29T20:10:54.527+00:00

Hi,
I have been trying to register PnP.Powershell in my tenancy to use with SharePoint online. I am a global admin and can connect and use Connect-SPOService with no issues. When I try to run Register-PnP.Powershell I get the following error:
"You did not consent for the PnP Management Shell Application for use by PnP PowerShell. Feel free to close this browser window.
Error details: error invalid_client error_description:AADSTS650052: The app is trying to access a service '...'(Dataverse) that your organization '...' lacks a service principal for. Contact your IT Admin to review the configuration of your service subscriptions or consent to the application in order to create the required service principal. Trace ID: 5fa6c6a2-4dae-4313-8740-a18e31f65802 Correlation ID: 42c25333-7cf3-4e6e-b51b-aa92ed59a3b8
The usual screen listing all permissions required does not appear, and jumps to the error.
I have also tried to use the -ShowConsentUrl option to no avail.
I have tried this in my personal Dev environment with no issues.
Any assistance would be greatly appreciated.
Cheers,
Nathan

Microsoft 365 and Office SharePoint Development
{count} votes

5 answers

Sort by: Most helpful
  1. Emily Du-MSFT 51,836 Reputation points Microsoft External Staff
    2022-12-30T08:41:34.313+00:00

    @Nathan Metzler

    Whether this error occurs when you run connect-PnPOnline?

    You could try to clear browser cache then register PnP.Powershell again.

    Since this question is more related to azure active directory, for better user experience, I have added "azure-active-directory" and "azure-ad-app-consent" tags.

    Here are similar questions for you:

    https://learn.microsoft.com/en-us/answers/questions/218696/pnp-error-when-connect-pnponline.html

    https://github.com/pnp/sp-starter-kit/issues/436


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Samarth Aaryan 1 Reputation point Microsoft Employee
    2022-12-30T17:36:12.55+00:00

    Hi @Nathan Metzler ,

    Does MFA enabled for the admin account which is used to execute PS?

    If yes, then please disable and check again


  3. Nathan Metzler 1 Reputation point
    2023-01-03T12:32:53.497+00:00

    Hi @JamesTran-MSFT , thanks for your reply.

    I am trying to run "Register-PnPManagementShellAccess" which is giving me the error.
    I have not manually set up an application to authenticate with before so I will try that sometime today.

    Regards
    Nathan

    0 comments No comments

  4. Nathan Metzler 1 Reputation point
    2023-01-13T12:16:32.7866667+00:00

    I am not sure if this is the way to do this but I believe I found the answer myself.

    I was on the right track when I mentioned it seemed like the "flow" was not triggering for the permissions consent form. I took this a step further and realized this is most likely a licensing issue as the tenancy is only utilizing SharePoint Plan 1 for all users. SP plan 1 does not include Flow from what I can see, so it makes sense for a flow to "not run" when triggered. If I can get approval, I will apply an enterprise license for the account and properly test the theory.

    Nathan

    0 comments No comments

  5. Bijay Kumar Sahoo 1 Reputation point MVP
    2024-02-27T18:53:32.27+00:00

    Today, I faced this issue and found a tricky way to solve this issue "register-pnpmanagementshellaccess is not recognized". Here is the solution: Register-PnPManagementShellAccess is not recognized I hope it might work for you as well.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.