I am Looking for a PowerShell Script which can download Bulk Data from SharePoint Document Library to a hard Disk with Metadata of each data in a CSV file. I also want log File for a documents which are successfully downloaded.
1 Answer
I have done the same some months ago. See the following sample:
$destination = "C:\\tools\\Folder"
$webUrl = "<Url of the specific site>"
$listUrl = "<Url of the specific list. This url is complete Url and NOT relative url>"
##############################################################
$web = Get-SPWeb -Identity $webUrl
$list = $web.GetList($listUrl)
function ProcessFolder {
param($folderUrl)
$folder = $web.GetFolder($folderUrl)
foreach ($file in $folder.Files) {
#Ensure destination directory
$destinationfolder = $destination + "/" + $folder.Url
if (!(Test-Path -path $destinationfolder))
{
$dest = New-Item $destinationfolder -type directory
}
#Download file
$binary = $file.OpenBinary()
$stream = New-Object System.IO.FileStream($destinationfolder + "/" + $file.Name), Create
$writer = New-Object System.IO.BinaryWriter($stream)
$writer.write($binary)
$writer.Close()
}
}
#Download root files
ProcessFolder($list.RootFolder.Url)
#Download files in folders
foreach ($folder in $list.Folders) {
ProcessFolder($folder.Url)
}
-
I have this PowerShell but it doesn't copy Metadata and log in CSV file. I want Metadata to be copied to CSV file while downloading Commented Feb 26, 2014 at 12:20