1

I can copy a file from one site to another using

$SPFolder_Destination.Files.Add("Filename.ext", $SPFile_Source.OpenBinary(), $false)

This does not preserve version history.

I think I could possibly download all versions and then upload as new versions, but as you can see that is quite a mess.

Does anyone know any easier ways to transfer/copy a file between sites (on the same server) which maintains version history? I'm using SP2010.

Thanks.

  • Is it mandatory to use powershell? Can't you use server object model? – Aanchal Jun 4 '14 at 7:35
  • Forgive my ignorance, but doesn't Powershell use this object model anyway? – Sam Jun 5 '14 at 5:58
0

The behavior is by design, the version history of a document is relative to its original document library. When you move the document to another library, it is considered as a new document there, when the metadata is copied, it changes minor version. There is no Non-coding solution for this.

Also look at below blog to copy files with version history using Server side object model:

http://sharepointvenividivici.typepad.com/sharepoint-customization/2011/06/maintain-file-version-history-when-movingcopying-files-between-sharepoint-sites.html

You can try with its powershell equivalent code if you want to acheive this by powershell only.

0

The SPExportObject object and SPImport object seem to provide what I need.

This technet blog post provided the solution in C#, which I translated to Powershell.

Unfortunately at that point I ran into the same problems as the user in this post. Like him, I could not get the event handler to work correctly and like him, I bit the bullet and implemented the entire thing in C#.

It is now working (more or less) as desired.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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