29 thoughts on “Connect-PnPOnline, Common error messages

  1. commented on July 4, 2016 by Merly

    how about for 502 bad gateway error?

    • commented on July 4, 2016 by Pieter Veenstra

      I guess a 502 error points towards a general network misconfiguration. Do you have any way you can reproduce this error?

  2. commented on September 26, 2017 by Poovi

    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.

    • 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)

      • commented on September 27, 2017 by Poovi

        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,


      • 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

        and then all my lists are returned.

  3. commented on September 27, 2017 by Poovi

    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.


  4. Yes you can, use Get-PnPProvisioningTemplate and Apply-PnPProvisioiningTempate

  5. commented on October 9, 2017 by Poovi


    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?


  6. commented on November 17, 2017 by Joe

    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?


    • 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.

      • commented on November 17, 2017 by Joe

        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.


      • commented on November 17, 2017 by Joe

        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

      • It shouldn’t be needed to use the app permissions, but it is an option. I would be interested to see if other admins can connect.

  7. commented on April 13, 2018 by Megha Bachani

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

  8. commented on April 13, 2018 by Megha Bachani

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

  9. commented on March 25, 2019 by Jesper Simonsen

    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

    • 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?

      • commented on March 26, 2019 by Jesper Simonsen

        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?

      • 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)";

      • commented on March 26, 2019 by Jesper Simonsen

        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

      • I’m glad I was able to help, even though it probably just fixed itself.

  10. commented on September 3, 2019 by Cheick Ali M. DIALLO

    Thanks a lot !

Leave a Reply to Pieter Veenstra Cancel reply

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

%d bloggers like this: