Connect-PnPOnline background

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

Connect-PnPOnline, Common error messages Microsoft Office 365, Microsoft SharePoint Online, PowerShell 687474703a2f2f692e696d6775722e636f6d2f6c3031686876452e706e67

To connect to Office 365 with PowerShell you have to use Connect-PnPOnline.

Quite often I’m getting errors as I’m mistyping something in the syntax of the Connect-PnPOnline command.

Here are a list of common errors for Connect-PnPOnline:

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.

Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

31 thoughts on “Connect-PnPOnline, Common error messages”
  1. Hi,
    I have downloaded and installed the SharePointonline module in powershell and trying to connect to office 365 environment.
    Once i use the below comment

    Connect-PnPOnline –Url mysiteurl -AuthenticationMode FormsAuthentication –Credentials (Get-Credential)
    After connecting to the site i tried to get lists of all or tried to create new list,site.But am getting Get-PnPList : The user’s login name or password is not valid.error.
    Please clarify.
    I tried windows credential method also but same issue.
    Waiting for early reply.
    Thanks
    Poovi

    1. There shouldn’t be a need for the forms parameter. That is more for on-premises configurations.

      Have you tried this:

      Connect-PnPOnline –Url mysiteurl –Credentials (Get-Credential)

      1. Hi,
        Thanks for the quick reply.
        I have tried that too.I have used windows credential method and tried the command.Now also it is prompting for credentials.Once given the connection is successful.
        Now my agenda is below.
        We have some custom lists with customized forms,JS files and associated with sharepoint designer workflows.Now to make the deployment automated need to use PNP powershell script for deploying to other environment.
        Currently we are taking list template and moving to production and Copying the workflow stages from one to other and copy pasting the js files.
        So could you please help me to do this using PnP powershell script for one sample list?

        Hope am clear with my requirement,

        Thanks
        POovi

      2. I’m doing something like this:

        $cred = Get-Credential -Message "Please enter password" -UserName "pieter@mytenant.onmicrosoft.com"
        Connect-PnPOnline https://mytenant.sharepoint.com/sites/testteamsite -Credentials $cred
        Get-PnPList

        and then all my lists are returned.

  2. Thanks for your reply.
    Can we copy and paste SharePoint designer workflow attached to one custom list in one site to UAT site using PnP power shell provisioning?
    Can we copy and paste the js files referencing the custom list using PnP power shell?

    Please clarify.

    Thanks
    Poovi

  3. Hi,

    What is the difference between Connect-SPOnline and Connect PnpOnline powershell commands?
    why we need to use PnP powershell scripts when we have Sponline already and what is the core benefit of this?

    Poovi

  4. Hello: thanks for the information but I am running into the “sign-in name or password does not match one in the Microsoft account system”. I’m running $cred = Get-Credential -Message “Please enter password” -UserName “pieter@mytenant.onmicrosoft.com”
    Connect-PnPOnline https://mytenant.sharepoint.com/sites/testteamsite -Credentials $cred
    Get-PnPList, where I use my creds, same as those I connect to sposervice with. Any further suggestions?

    Thanks,
    Joe

    1. I’m assuming that you have replaced all the tenant names in my example with your own tenant details.

      So are you getting the error during the Connect-PnPOnline or are you getting the error during the Get-PnPList. Get-PnPList doesn’t work until a valid connection has been setup.

      I would initially try to copy paste the username and password from text editer like notepad. When you copy paste the username and password from a text editor into the credential boxes does it still not work?

      If it still doesn’t work, can you try it as a different administrator user?

      Do you have any additional security features in place or is this just a standard Office configuration? So things like MFA.

      1. Wow, thanks for the quick response. Yes, i changed the tenant details, we do have MFA enabled. I get the error at Connect-PNPOnline, I was typing in the user name/pw, but will try what you suggest. If that doesn’t work I’ll ask another admin to give it a try.

        Thanks,
        Joe

      2. Hello Sir, your question on additional security features made me think i should try creating an app password. That did the trick. I hadn’t thought I would’ve needed to do that as I had already had one for Powershell, but that did the trick. Thanks. Joe

  5. I got error: The underlying connection was closed: unexpected error occurred on a receive.
    and same information as 403 error mentioned by you

  6. I use an xml file, I also tried to use get-credential, both work when I try typing commands, but not in the script

  7. I have a new error message for connect-PnPOnline.
    When I’m running the below powershell in SharePoint Online Management Shell it works.
    But if I run it in a Azure Function it fails.

    $secpasswd = ConvertTo-SecureString ‘Pa$$word’ -AsPlainText -Force
    $mycreds = New-Object System.Management.Automation.PSCredential (‘SPUser@myTenant.com’, $secpasswd)
    $sourcectx = connect-PnPOnline -Credentials $mycreds -url ‘https://myTenant.sharepoint.com/sites/Projects’

    2019-03-25T15:25:08.733 [Error] connect-PnPOnline : The operation has timed out
    at run.ps1: line 131
    + connect-PnPOnline
    + _________________
    + CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], WebException
    + FullyQualifiedErrorId : System.Net.WebException,SharePointPnP.PowerShell.Commands.Base.ConnectOnline

    Weird thing is it has been running for months, it’s unchanged, user is site owner, password never expires, SharePointPnP is at latest version.

    Have you seen this before and do you have any ideas what I should be looking for?

    Best regards, Jesper

    1. It could just be a matter of updates being on their way. Are you able to connect any other way? Can you try connect-PnPOnline -Credentials $mycreds -url ‘https://myTenant.sharepoint.com/sites/Projects’ -UseWebLogin from a new machine? Did you enable MFA?

      1. I can run the PowerShell successfully in the SharePoint Online Management Shell, but when I have it in an Azure v1.0 function it used to work, but now it has stopped.
        MFA is not enable for the user and -UseWebLogin does not work together with -Credentials $mycreds.
        I’m also guessing on some update or something tenant specific, is there any advanced logs I could look at?

      2. I just quickly tried connecting from an Azure Function in my environment and it just worked.
        You could try and create a new function. Does the same error happen? Also maybe try and connect to a different tenant.

        Write-Output "PowerShell Timer trigger function executed at:$(get-date)";

        Set-Location "D:\home\site\wwwroot\TimerTriggerPowerShell1"

        if ($env:PSModulePath -contains "./Modules")
        {
        Write-Output "No need to add ./Modules"
        Write-Output $env:PSModulePath
        } else
        {
        $env:PSModulePath = $env:PSModulePath + ";./Modules"
        }

        $secpasswd = ConvertTo-SecureString 'MyPass' -AsPlainText -Force
        $mycreds = New-Object System.Management.Automation.PSCredential ('user@mytenant.onmicrosoft.com', $secpasswd)

        Connect-PnPOnline https://pieterveenstramvp.sharepoint.com -Credentials $mycreds

        Write-Output "PowerShell Timer trigger function executed at:$(get-date)";

      3. I have tried creating a new function and the same error occurred.
        But now, just a minute ago, without me doing anything, it started working again, same script, same credentials. No clue as to what happened.
        But thank you so much for your help and support.
        PS. for some reason there’s no Reply link on your latest reply so that’s why I’m replying here

  8. PLS CAN YOU HELP FOR THIS QUERY 😦

    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’.
    Trace ID: bbceed21-03b3-4292-8d0f-c39945af3601
    Correlation ID: c6635c12-aa7c-4491-9b36-bd1344606d48
    Timestamp: 2021-04-27 07:31:43Z
    At line:1 char:1
    + connect-PNPonline
    + ~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], MsalUiRequiredException
    + FullyQualifiedErrorId : Microsoft.Identity.Client.MsalUiRequiredException,PnP.PowerShell.Commands.Base.ConnectOnline

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading