“connect-pnponline -PnPO365ManagementShell -launchbrowser”is raising this Error:- “Object reference not set to an instance of an object.”

john john 1,026 Reputation points
2021-01-19T21:49:45.66+00:00

I am trying to connect to a SharePoint online communication site which have MFA enabled, I tried running this command:

PS C:\WINDOWS\system32>  connect-pnponline "https://***.sharepoint.com/sites/***/"  -PnPO365ManagementShell -launchbrowser  

where i will get a popup >> then i will enter the code >> enter username and password >> close the popup >> but I got this error:

WARNING: To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code D****9  
to authenticate.  
WARNING: Code has been copied to clipboard  
connect-pnponline : Object reference not set to an instance of an object.  
At line:1 char:2  

Although I entered the above code and enter the username and password and confirm the MFA.

Anyone advice please?

here is the popup which i closed:-

58206-popup.png

Microsoft 365 and Office | SharePoint | For business | Windows
{count} votes

2 answers

Sort by: Most helpful
  1. trevorseward 11,711 Reputation points
    2021-01-19T23:44:21.213+00:00

    Do the following work:

    • Connect-PnPOnline -UseWebLogin
    • Connect-PnPOnline -SPOManagementShell

    Also, the PnP cmdlets have been replaced with the module PnP.PowerShell if you want to try the new ones out.

    0 comments No comments

  2. Jerry Xu-MSFT 7,961 Reputation points
    2021-01-20T06:07:37.683+00:00

    Hi, @john john ,

    I tested with the cmdlets provided by Trevor and both works with MFA enabled account. Please have a try with the them.

    The connect-pnponline "https://***.sharepoint.com/sites/***/" -PnPO365ManagementShell -launchbrowser stuck after I entering the credential.


    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.

    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.