I need a PowerShell script that should extract all of the site contents to a CSV-file. This means Lists, and libraries item collection with sub-folder items. Additionally it should extract the sub-site details as well.

  • 3
    This would possibly require a longish script which iterates through each site's each library & list and each of their contents and finally combines them to a one file. For what I'm aware of, no such solution exists. While we have many ambitious and exemplary users in here, it's not the most likely case you would receive a solution created from a scratch. Therefore it would be great to see you had tried to create a solution of your own, where did you get and what possible problems you faced.
    – moe
    May 25, 2017 at 6:05
  • I disagree that this would be a long script. Loop through the sites, loop through the lists, loop through the list items. There are one-liners for each of those. Google "PnP PowerShell". May 25, 2017 at 13:41

2 Answers 2


You can use the csom powershell script to export 1. All Sub sites in a single site collection 2. All Lists and libraries in a site 3. all List items from all lists in a site 4. All Library items from all libraries in a site.

You need to use Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll this references where ever the powershell files.

you can download all 4 powershell files and dlls from this location. you run one by one in order they will generate all csv files. Make sure you open each file and provide the Web url, site collection url , user name, password.


Why don't you use Export-SPWeb? This exports all site content, including lists and sub sites, to a file. Here is some info.

  • While Export-SPWeb does this, I'm afraid its syntax is far from CSV.
    – moe
    May 25, 2017 at 6:23
  • Yea it is. I'm afraid I missed what @Rajendar mean at question.
    – newbie
    May 25, 2017 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.