Forum Discussion

sunnypasrija's avatar
sunnypasrija
Copper Contributor
Jun 21, 2021

Connect-PnpOnline: Getting error Length can not be zero. Parameter:Length

While connecting to SharePoint Online inside azure queue function I am getting  error "Length can not be zero. Parameter:Length". I am using self signed certificate, key and Client ID to connect to sharepoint online. Anyone else facing the same issue ?

  • Phildo25's avatar
    Phildo25
    Copper Contributor

    sunnypasrija 

     

    I had the same problem and it was because I was using the older SharePointPnPPowerShellOnline Module. Where as pnp.powershell is the newer one that should be used

     

    Then I had this error

    Index was out of range. Must be non-negative and less than the size of | the collection. (Parameter 'startIndex')

     

    But the above one was fixed by switching from the powershell 7.1 runtime to powershell 5.1

  • mmr104's avatar
    mmr104
    Copper Contributor

    sunnypasrija Did you figure out a solution for this? I am getting the same error when connecting to SharePoint Online with Azure Automation.

    • LHoffmannUdS's avatar
      LHoffmannUdS
      Copper Contributor

      sunnypasrija 

      mmr104 

       

      Is there a solution jet? I have the same problem now too. I got the base64 encoded certificate and I can connect to pnpOnline via cloud-shell but not within a automation runbook. I get the same error: 

       

      Line |
        30 |  Connect-PnPOnline -Url $baseSite -ClientId $appId -CertificateBase64E …
           |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           | Length cannot be less than zero. (Parameter 'length')

       

Resources