I recently saw a post (maybe on Reddit) where someone was asking for a script that would download all the files in a SharePoint site. I found myself with a few spare minutes and an open ChatGPT window, so I took a swing at it. I think the results turned out pretty well. I do want to give a shout out to the Salaudeen Rajack at SharePoint Diary. We did get some help from this script of his.
To give the script a wider audience, I submitted it to the PnP Script Samples Gallery. You can download it here.
I tried to write it as well as I could, so I wrote it as a function inside of a module file. Because of that you have to save the script as a PSM1 file (as opposed to a regular old PS1 file). Then use Import-Module to import that PSM1 file, which adds my function, Download-SharePointFiles to your PowerShell host. Then run Download-SharePointFiles with the correct parameters. It looks like this:
That gives you output that looks like this:
I hope you find it helpful. Let me know in the comments if there’s any functionality you’d like me to add.
tk
About the Author
Todd Klindt
I’m an 12 time SharePoint MVP that focuses on the Admin or IT Pro side of SharePoint, Office 365, and Azure. I leave the Development and End-User content up to the professionals. I’ve been working with SharePoint since SharePoint Team Services 2001 and it’s put food on my table for more than a decade.
I also speak at tech events like the Microsoft SharePoint Conference, TechEd, Ignite, SharePoint Evolution, DevIntersection, and various and sundry SharePoint Saturday events.
Over the years I’ve also developed a lot of fondness for other Microsoft technologies like PowerShell, SQL, and most recently Azure AD.I love how I can make them work all together.
Reference:
Klindt, T (2025). PowerShell Script to Download all Documents from all Doclibs, Versions Included – Todd Klindt’s Blog [Accessed: 11th October 2025].