SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a WorkFlow to create a document populating it with data from a list. I now need a powershell script that can copy the file in the document library to a file share on our server.

I am new to using powershell in SharePoint, is this possible with a script?

share|improve this question
yes it is possible – Sebastien Stettler Mar 1 '12 at 12:18
@SebastienStettler I did find a post on this site… It included a script which I have altered which copies files however how would I change it to only fetch a single file? – Jonathan F Mar 1 '12 at 13:33

You can use this method.

$fileUrl = url for file on sharepoint

$destinationfolder = destinationFolder

function ProcessURL {
    $file = $web.GetFile($fileUrl)
        $destinationfolder = $destination + "/" + $folder.Url 
        if (!(Test-Path -path $destinationfolder))
            $dest = New-Item $destinationfolder -type directory 
        #Download file
        $binary = $file.OpenBinary()
        $stream = New-Object System.IO.FileStream($destinationfolder + "/" + $file.Name), Create
        $writer = New-Object System.IO.BinaryWriter($stream)
        #Delete file by deleting parent SPListItem
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.