Welcome to an article on how to get all documents from a SharePoint Document Library to a local folder using PowerShell Script.
Sometimes we need all our files in a document library for a requirement and if there are many you can’t download one by one or use ‘Open with explorer option’ if your company policy does not allows you to use this function.
You have a choice, using this script which will take hardly any time to download all your documents at once to your local folder.
How? Let’s see it.
1. Open Windows PowerShell Modules as an Administrator.
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
# Call the Web Service here $SPWeb = Get-SPWeb "Provide your web here"
# Open the library here
$docfiles = $SPWeb.GetFolder("Provide your Document Library name here").Files
foreach ($docfile in $docfiles)
# Download each file here
Write-host "Download Completed for" $docfile. Name
$bin = $docfile.OpenBinary()
$opendoc = New-Object System.IO.FileStream(("Provide your Local Location here"+$docfile. Name), [System.IO.FileMode]::Create)
$docgen = New-Object System.IO.BinaryWriter($opendoc)
2. Save the above code in a notepad as .ps1 file.
3. Run the code on the Windows PowerShell Modules.
4. It will display the file name it is downloading and all the files will start getting downloaded to your local.
It will be so quick that you won’t take much time and effort on this, thereby saving a lot of time and effort. Run the script and you have all the files on your local server.