manoj´ssharepointblog

SharePoint Blog


Leave a comment

Download a file from SharePoint using Power Shell

$fromsite = “http://ServerrURL/sites/yoursite”
$fromfile = “documentLibrary/yourfile.xlsx”
$tofile = “c:\test\yourfile.xlsx”
$web = Get-SPWeb $fromsite
$file = $web.GetFile($fromfile)
$filebytes = $file.OpenBinary()
$filestream = New-Object System.IO.FileStream($tofile, “Create”)
$binarywriter = New-Object System.IO.BinaryWriter($filestream)
$binarywriter.write($filebytes)
$binarywriter.Close()

Advertisements