Download all files from library

pnp logo

Hello everyone,

Today I’ll share a little PowerShell script I made some time ago. It allows you to download all files of a single library, looping through all subfolders. This script use PNP PowerShell .

It was done for Office365 but should work the same way for onpremise. You just need to update the parameter on the top and run it. It will prompt you for your credentials to access the site and then download all the files to the specified directory (creating it if it doesn’t exist)

Hoping this helps!

Christopher

 

Advertisements

SyntaxError Unexpected token in JSON at position 0

Hello everyone,

Today I will talk about a problem concerning the use of PNP JS Core on an environment 2013 OnPremise.

Problematic

Like many I started using PNP JS Core for my developments. After retrieving some information and doing some conclusive tests on an Office 365 environment, I wanted to reuse my code on a SharePoint 2013 OnPremise.

And there .. Boom!

SyntaxError: Unexpected token < in JSON at position 0

The code does not have anything complicated, it will only read the contents of a list.

Reason

Looking a bit, I saw that the return of the REST call was XML and not JSON. It seems that this comes from the basic configuration of SharePoint 2013 SP1 https://github.com/SharePoint/PnP-JS-Core/issues/125

Resolution

The solution to this problem is to pass a configuration before making the call: https://github.com/SharePoint/PnP-JS-Core/pull/127

pnp.setup({
        headers: {
            "Accept": "application/json; odata=verbose"
        }
    });

Simple but when you start using PNP JS it can be useful to know.

Hoping it helps.

NB : Thanks to Yannick for helping the noobie I was in this situation !

Christopher.