pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
990 stars 663 forks source link

MFA and Connect-PnPOnline -PnPO365ManagementShell Errors with Object reference not set to an instance of an object #1621

Open pmatthews05 opened 6 years ago

pmatthews05 commented 6 years ago

Reporting an Issue or Missing Feature

Error

Expected behavior

Connect to SharePoint using an account with MFA user and the -PnPO365ManagementShell

Actual behavior

After authenticating, I get an Object reference not set to an instance of an object error message.

Steps to reproduce behavior

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

2.27.1806.1

How did you install the PnP-PowerShell Cmdlets?

andrewpat24 commented 6 years ago

I'm having the same issue and what I find weird about it is that this error is in reference to the credentials dialog getting cancelled.

I wonder if the credentials dialog is still sending the "this dialog has been cancelled" response once it gets closed from logging in?

Edit:

I ended up using this approach to resolve my issue and get access to the tenant with mfa:

Connect-PnPOnline –Url https://[tenant]-admin.sharepoint.com/ -UseWebLogin;

fidesimon commented 6 years ago

I'm having the same issue. It never works when I use "PnPO365ManagementShell" parameter. I would receive a message saying "Token Received" but then there is the same error - "Object reference not set to an instance of an object." (when i use -LaunchBrowser), or "The property or field 'ServerLibraryVersion' has not been initialized or the request has not been executed. It may need to be explicitly requested." (when I do not use -LaunchBrowser) I tried -UseWebLogin and it works for my dev tenancy, but not for the production as there are both: MFA and a federated login - the login dialog appears, but it stays blank.

remcovn commented 5 years ago

I'm experiencing exactly the same issue. When I use the 'PnPO365ManagementShell' option without the 'LaunchBrowser' option I get the following output:

Connect-PnPonline https://hidden.sharepoint.com -PnPO365ManagementShell
WARNING: To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code A12BC3DEF to authenticate.
...........................Token receivedconnect-pnponline : The property or field 'ServerLibraryVersion' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
At line:1 char:1
+ connect-pnponline https://hidden.sharepoint.com -PnPO365Management ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-PnPOnline], PropertyOrFieldNotInitializedException
    + FullyQualifiedErrorId : Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException,SharePointPnP.PowerShell.Commands.Base.ConnectOnline

When I use the 'LaunchBrowser' option, the following output is returned:

connect-pnponline https://hidden.sharepoint.com -PnPO365ManagementShell -launchbrowser
WARNING: To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code A12BC3DEF to authenticate.
WARNING: Code has been copied to clipboard
connect-pnponline : De objectverwijzing is niet op een exemplaar van een object ingesteld.
At line:1 char:1
+ connect-pnponline https://hidden.sharepoint.com -PnPO365Management ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-PnPOnline], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,SharePointPnP.PowerShell.Commands.Base.ConnectOnline

We are using a federated logon by using AD FS and we have Conditional Access with MFA enabled for our admin users.