{"id":1564,"date":"2013-10-16T07:11:01","date_gmt":"2013-10-16T07:11:01","guid":{"rendered":"https:\/\/poiseddevelopers.com\/reality-tech\/?p=1564"},"modified":"2024-05-06T12:24:01","modified_gmt":"2024-05-06T12:24:01","slug":"how-to-write-a-sharepoint-file-to-disk","status":"publish","type":"post","link":"https:\/\/poiseddevelopers.com\/reality-tech\/how-to-write-an-spfile-to-disk\/","title":{"rendered":"How to write a SharePoint File to disk"},"content":{"rendered":"<p>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\u2019s how:<\/p>\n<pre lang=\"php\">$site = New-Object Microsoft.SharePoint.SPSite($SharePoint Location) \r\n$web = $site.OpenWeb() \r\n$item = $web.GetListItem($SharePoint Location) \r\n$fileStream = ( $item.file.OpenBinary())\r\n$stream = New-Object System.IO.FileStream($LocalDiskFileLocation ,[System.IO.FileMode]::Create)\r\n$writer = New-Object System.IO.BinaryWriter($stream)        \r\n$writer.write($fileStream)        \r\n$writer.Close()\r\n<\/pre>\n<p><strong>Additonal Read<\/strong><br \/>\n<a style=\"color: #1f6799;\" href=\"https:\/\/poiseddevelopers.com\/reality-tech\/sharepoint-document-ids\/\" target=\"_blank\" rel=\"noopener\">SharePoint Document IDs<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u2019s 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) [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":1565,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[26],"tags":[],"class_list":["post-1564","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"_links":{"self":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/comments?post=1564"}],"version-history":[{"count":7,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1564\/revisions"}],"predecessor-version":[{"id":3546,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1564\/revisions\/3546"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media\/1565"}],"wp:attachment":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media?parent=1564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/categories?post=1564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/tags?post=1564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}