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

Jaydeep Patel

Updated On: April 01, 2026

All Posts
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

Have a question?

We’re here to help. Get in touch with us anytime, 24/7

Newsletters