Error
Connect to SharePoint using an account with MFA user and the -PnPO365ManagementShell
After authenticating, I get an Object reference not set to an instance of an object error message.
With my Powershell window I type in
Connect-PnPOnline -PnPO365ManagementShell:$true -Url:https://mytestsite.sharepoint.com/sites/June -ReturnConnection:$true -LaunchBrowser:$true
The device Login page appears, I paste the code in
The Window displays PnP Office 365 Management Shell, clicked Continue.
Pick an account - I pick my account, enter UserName and Password, run through my MFA step
The powershell windows says Token Received, followed by
Connect-PnPOnline : Object reference not set to an instance of an object.
At line:1 char:1
+ Connect-PnPOnline -PnPO365ManagementShell:$true -Url:https://mytestsite ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,SharePointPnP.PowerShell.Commands.Base.ConnectOnline
Screenshot included
2.27.1806.1
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 鈥揢rl https://[tenant]-admin.sharepoint.com/ -UseWebLogin;
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.
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.
Most helpful comment
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 鈥揢rl https://[tenant]-admin.sharepoint.com/ -UseWebLogin;