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.
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.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.