29 thoughts on “Office 365 – SharePoint – Connect-SPOnline/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

    Like

      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

        Like

      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.

        Like

  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

    Like

  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

    Like

  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

    Like

    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.

      Like

      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

        Like

      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

        Like

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

    Like

  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

    Like

  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

    Like

    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?

      Like

      1. I can run the PowerShell succesfully 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?

        Like

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

        Like

      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

        Like

Please leave a comment or feedback

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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