Download All Documents in SharePoint Web using Powershell Script

In this blog post I'm going to show you how to download all document using Powershell script on your local drive.
Please follow the below steps:
1. Creating commandlet bindings (command variables)
2. Add-PSSnapin statement for importing SharePoint library.
3. Now creating a recursive function for traversing all the folders in the specified folder and downloading it to local folder.
In the second foreach loop we are checking if Folder not exists on local drive then create the folder and then call DownloadAllItemInFolder function recursively.
4. Create the instance of Site, Web and Folder to call  DownloadAllItemInFolder function.
Once the downloading finished, dispose off the Site object.
Full script can be downloaded from here.
Below is the sample command to run this script.

.\DownloadSPFiles -SiteCollectionUrl "http://siteurl" -SPFolderPath "<Folder>" -LocalDir "C:\BackupFiles"

In that script I've used the Root Web for downloading the files. You can also change the web from which you want download the files. In the next post I'm going to add a function for recursively calling all webs in rootweb and then downloading all files. So stay tuned and wait for the next post.
Enjoy!!!!

Comments

Post a Comment

Popular posts from this blog

Installation and Configuration of Office Online Server with SharePoint 2019

Workflow Manager 1.0- Installation, Configuration and Issues

SharePoint 2019 Upgrade Part 6: SharePoint Upgrade Issues