Note: Recently the Connect-SPOnline command was replaced with Connect-PnPOnline. 

To connect to Office 365 with PowerShell you have to use Connect-SPOnline. Quite often I’m getting errors as I’m mistyping something. Here are a list of common errors:

Object reference not set to an instance of an object.

Connect-SPOnline : Object reference not set to an instance of an object.
At line:1 char:1
+ Connect-SPOnline -Url https://tenant.sharepoint.com
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Connect-SPOnline], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,OfficeDevPnP.PowerShell.Commands.Base.ConnectSPOnline

This happens when the credentials dialog is cancelled.

Identity Client Runtime Library (IDCRL) could not look up the realm information for a federated sign-in

Connect-SPOnline : Identity Client Runtime Library (IDCRL) could not look up the realm information for a federated sign-in.
At line:1 char:1
+ Connect-SPOnline -Url https://tenant.sharepoint.com
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Connect-SPOnline], IdcrlException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.IdcrlException,OfficeDevPnP.PowerShell.Commands.Base.ConnectSPOnline

This error appear when you type the wrong user account. Typically when I use myuser@pieterveenstra.sharepoint.com instead of myuser@pieterveenstra.onmicrosoft.com

The sign-in name or password does not match one in the Microsoft account system.

Connect-SPOnline : The sign-in name or password does not match one in the Microsoft account system.
At line:1 char:1
+ Connect-SPOnline -Url https://tenant.sharepoint.com
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Connect-SPOnline], IdcrlException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.IdcrlException,OfficeDevPnP.PowerShell.Commands.Base.ConnectSPOnline

This happens when you mistype the password. 😉

The remote server returned an error: (403) Forbidden.

Connect-SPOnline : The remote server returned an error: (403) Forbidden.
At line:1 char:1
+ Connect-SPOnline -Url https://tenant.sharepoint.com -CurrentC …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Connect-SPOnline], WebException
+ FullyQualifiedErrorId : System.Net.WebException,OfficeDevPnP.PowerShell.Commands.Base.ConnectSPOnline

This happens when you use the -CurrentCredentials switch and your current user doesn’t have access to your site. The same error is also thrown if you try to connect to a sub site and the subsite doesn’t exist

Also see: https://github.com/SharePoint/PnP-Sites-Core/issues/615

 

Unable to connect to the remote server

Connect-SPOnline : Unable to connect to the remote server
At line:4 char:1
+ Connect-SPOnline -Url https://tenant.sharepoint.com
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Connect-SPOnline], WebException
+ FullyQualifiedErrorId : System.Net.WebException,OfficeDevPnP.PowerShell.Commands.Base.ConnectSPOnline

The Unable to connect to remote server error may occur if your url resolves to an incorrect ip address. I got this when I updated my host file with an invalid IP address. I’m not sure why you would do this but it’s another possible error that you may receive.

 

Connect-SPOnline : The account password has expired, as specified by the account settings.

Connect-SPOnline : The account password has expired, as specified by the account settings.
At line:1 char:1
+ Connect-SPOnline -Url https://tenant.sharepoint.com
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Connect-SPOnline], IdcrlException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.IdcrlException,OfficeDevPnP.PowerShell.Commands.Base.ConnectSPOnline

Well this is an easy one,  but I had to wait a few months before I came across it ;-). My password had expired. I was connecting to my site using PowerShell before I reset my password.

Error establishing a connection

Connect-SPOnline : Error establishing a connection
At line:1 char:1
+ Connect-SPOnline -Url https://portal.mycompany.com -Cred …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-SPOnline], Exception
+ FullyQualifiedErrorId : System.Exception,SharePointPnP.PowerShell.Commands.Base.ConnectSPOnline

This happened when I tried to connect to an on-premises environment where a forms based solution was implemented.

The remote server returned an error: (407) Proxy Authentication Required

Connect-SPOnline : The remote server returned an error: (407) Proxy
Authentication Required.
At C:\Users\pveenstra\Downloads\test.ps1:6 char:1
+ Connect-SPOnline $url -Credentials $credentials
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-SPOnline], WebException
+ FullyQualifiedErrorId : System.Net.WebException,SharePointPnP.PowerShell.Co
mmands.Base.ConnectSPOnline

This happens when you try to connect through a proxy server. In my case I was connecting to my customer’s SharePoint farm.  In my case I was able to avoid the proxy server and my problem disappeared.

The partner returned a bad sign-in name or password error

Connect-PnPOnline : The partner returned a bad sign-in name or password error. For more information, see Federation Error-handling Scenarios.
At line:1 char:1
+ Connect-PnPOnline -Url https://mycompany.sharepoint.com
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], IdcrlException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.IdcrlException,SharePointPnP.PowerShell.Commands.Base.ConnectOnline

This is was proxy related.

 

The partner returned a bad sign-in name or password error. For more information, see Federation Error-handling Scenarios.

Connect-PnPOnline https://mytenant.sharepoint.com/sites/myteamsite
Connect-PnPOnline : The partner returned a bad sign-in name or password error. For more information, see Federation Error-handling Scenarios.
At line:1 char:1
+ Connect-PnPOnline https://mytenant.sharepoint.com/sites/myteam
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], IdcrlException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.IdcrlException,SharePointPnP.PowerShell.Commands.Base.ConnectOnline

This issue happened when I logged onto my corporate SharePoint Online  team site Adding -AuthenticationMode FormsAuthentication resolved the issue:

PS U:\> Connect-PnPOnline https://mytenant.sharepoint.com/sites/myteamsite -UseWebLogin

 

 

 

If you have any more errors that you have come across then please leave a comment.

 

 

 

Advertisements