Unable to connect to PnP Powershell for SharePoint Online

Mukherjee, Nilanjan 46 Reputation points
2021-08-03T08:16:08.747+00:00

When connecting to pnp powershell , Connect-PnPOnline -Url <site url>-UseWebLogin, I am getting below error.

Connect-PnPOnline : AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a
new location, you must use multi-factor authentication to access '00000003-0000-0ff1-ce00-000000000000'.

Please help me to know why this is happening

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,684 questions
0 comments No comments
{count} votes

Accepted answer
  1. Echo Du_MSFT 17,116 Reputation points
    2021-08-04T02:39:47.047+00:00

    Hello @Mukherjee, Nilanjan ,

    Welcome to Q&A Forum!

    This is because the Connect-PnPOnline command with the Credential parameter is not work to MFA enabled accounts.

    If you have an account secured with MFA, when using PnP PowerShell you have to use the weblogin option which shows a popup to support MFA. It's an interactive process that you couldn't implement in a build pipeline. That's just the consequence of using MFA which always requires user interaction.

    Please use the below PnP powershell command:

    Connect-PnPOnline -Url "https://contoso.sharepoint.com" -UseWebLogin  
    

    OR

    Connect-PnPOnline -Url "https://contoso.sharepoint.com" -Interactive  
    

    For more information, please refer to "Connect-PnPOnline".

    Thanks,
    Echo Du

    ========================
    Updated Answer ======================

    Hi @Mukherjee, Nilanjan ,

    Please following steps:

    1.Update the module to latest version then compare the result:

    Update-Module SharePointPnPPowerShell*  
    

    2.You have to connect with Connect-PnPOnline -PnPManagementShell and then you will receive a code to enter on https://microsoft.com/devicelogin

    Connect-PnPOnline -Url "https://xxxx.sharepoint.com/" -PnPManagementShell  
    

    122649-1.png

    3.Type https://microsoft.com/devicelogin on the browser, where you will need to login with credentials for an account that must have the Application Admin role assigned to them in the Admin Center, and then you can consent to give PnP Management Shell access to your tenant.

    122650-2.png

    122711-3.png

    4.After that, you should be able to login with Connect-PnPOnline -Url <url> again.

    Thanks,
    Echo Du

    ===========================

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    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.

    3 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Mukherjee, Nilanjan 46 Reputation points
    2021-08-12T08:50:38.95+00:00

    Connect-PnPOnline -Url "https://contoso.sharepoint.com" -Interactive

    This solved the issue

    1 person found this answer helpful.