Search This Blog

Saturday, October 1, 2016

Download Particular Excel File From Library on Local server Location

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$fromsite = "http://ngo.com"

$fromfile = "NGODocument/NGO.xlsx"
$tofile   = "C:\NGODoc\NGODocument.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()

No comments:

Post a Comment