SharePoint 2010 and PowerShell: How to copy files from document library to another document library in the same site collection?


We want to copy item to another document library for archive or some other purpose like added extra column/information for searching, etc.

We want to get this achieved by using PowerShell.


$fromWeb = Get-SPWeb “http://….”
$libFile = $fromWeb.GetFile(“http://…/item.docx”)
$folder = $web.GetFolder(“Target Document Library”)
#Copy the file into the document library using file stream
$f = $folder.Files.Add($File.FileName, $libFile.OpenBinary(), $overwrite)
#Copy across the existing data
$item = $f.Item
$item[“Modified”] = $libFile.TimeLastModified.ToLocalTime()
$item[“Created”] = $libFile.TimeCreated.ToLocalTime()
$item[“Author”] = $libFile.Author
$item[“Modified By”] = $libFile.ModifiedBy

#To overwrite the property



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s