connect PnPOnline to add file to SharePointonline

Welcome Forums General PowerShell Q&A connect PnPOnline to add file to SharePointonline

  • This topic has 6 replies, 2 voices, and was last updated 1 month ago by
    Participant
    .
Viewing 3 reply threads
  • Author
    Posts
    • #279576
      Participant
      Topics: 1
      Replies: 3
      Points: 18
      Rank: Member

      I am not able to connect to sharepoint using below script

      $Mycredentials = Import-Clixml -Path “file1.xml”

      Connect-PnPOnline -Url $SiteUrl -Credentials $Mycredentials

      Add-PnPFile -Folder “folder1” -Path “file2.csv”

    • #279585
      Participant
      Topics: 5
      Replies: 249
      Points: 985
      Helping Hand
      Rank: Major Contributor

      Can you post the error message?

      • #279588
        Participant
        Topics: 1
        Replies: 3
        Points: 18
        Rank: Member

        Connect-PnPOnline : Object reference not set to an instance of an object.
        At line:12 char:1
        + Connect-PnPOnline -Url $SiteUrl -Credentials $Mycredentials
        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], NullReferenceException
        + FullyQualifiedErrorId : System.NullReferenceException,PnP.PowerShell.Commands.Base.ConnectOnline

        Add-PnPFile : Cannot contact site at the specified URL https://lspllc.sharepoint.com/sites/InformationSystemsTeam. The app principal does not
        exist.
        At line:21 char:1

    • #279597
      Participant
      Topics: 5
      Replies: 249
      Points: 985
      Helping Hand
      Rank: Major Contributor

      Deleted.

      • This reply was modified 1 month ago by Mike R..
      • #279600
        Participant
        Topics: 1
        Replies: 3
        Points: 18
        Rank: Member

        <Objs Version=”1.1.0.1″ xmlns=”http://schemas.microsoft.com/powershell/2004/04″&gt;
        <Obj RefId=”0″>
        <TN RefId=”0″>
        <T>System.Management.Automation.PSCredential</T>
        <T>System.Object</T>
        </TN>
        <ToString>System.Management.Automation.PSCredential</ToString>
        <Props>
        <S N=”UserName”>[email protected]</S>
        <SS N=”Password”>5aebd577fb6a140000006c4a0eb6f61bb18e6d200d7c8d3ee98685587b9d</SS>
        </Props>
        </Obj>
        </Objs>

      • #279603
        Participant
        Topics: 1
        Replies: 3
        Points: 18
        Rank: Member

        Also the account is set to use MFA.

        CAn that be an issue?

         

        I can connect to sharepoint with useWeblogin fine.

    • #279609
      Participant
      Topics: 5
      Replies: 249
      Points: 985
      Helping Hand
      Rank: Major Contributor

      I think MFA requires the -UseWebLogin switch.  From the docs:

      -UseWebLogin

      If you want to connect to SharePoint with browser based login. This is required when you have multi-factor authentication (MFA) enabled.

      The xml file is fine.  Try adding this switch to your Connect-PnPOnline command.

      This may not allow you to specify the credentials in the command because it is in a different parameter set….

      • This reply was modified 1 month ago by Mike R..
Viewing 3 reply threads
  • You must be logged in to reply to this topic.