How to write a SharePoint File to disk How to write a SharePoint File to disk
Jaydeep Patel

Jaydeep Patel

October 16, 2013

All Post
How to write a SharePoint File to disk 122
Share:

It is quite common, there is a file in SharePoint, and you want to see it written to a local disk. How to do that in PowerShell? Here’s how:

$site = New-Object Microsoft.SharePoint.SPSite($SharePoint Location) 
$web = $site.OpenWeb() 
$item = $web.GetListItem($SharePoint Location) 
$fileStream = ( $item.file.OpenBinary())
$stream = New-Object System.IO.FileStream($LocalDiskFileLocation ,[System.IO.FileMode]::Create)
$writer = New-Object System.IO.BinaryWriter($stream)        
$writer.write($fileStream)        
$writer.Close()

Additonal Read
SharePoint Document IDs

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to talk?

Drop us a line. We are here to answer your questions 24*7.