1

I'm fairly new to Powershell for SharePoint and have a run a few small scripts.

I was attempting to use this script to copy one library and its contents to another empty library. I couldn't do save as template because the library is too large.

https://blogs.msdn.microsoft.com/rcormier/2012/11/16/how-to-copy-sharepoint-documents-between-site-collections-using-powershell/

Is this script too old or just not compatible with SharePoint Online? I keep getting the " this cmdlet is not recognized

Any help or advice on this would be greatly appreciated or reference to some others scripts.

I am looking to copy the library, it's files and metadata.

2
  • The script you are referring supports for SharePoint on-premises environment. Commented May 26, 2017 at 18:28
  • @VenkatKonjeti thank you, that's what I thought. Any advice on how I can do this in the SharePoint online environment? Commented May 26, 2017 at 18:34

3 Answers 3

0

There are couple of options to copy files to new library

Synch and Copy You can sync both libraries to local drive and copy. This doesn`t require any coding.

  1. Sync source library
  2. Sync destination library
  3. Copy files and folders from source to the destination from your synced folders.

Note: It is not copying metadata

Use PnP PowerShell

It requires primary knowledge on PnP scripts and needs to setup PnP files on your local system.

You can copy file and metadata using your custom PowerShell script.

Refer the following link

Setup PnP PowerShell

Video to get started on copying files

Create Console Application

It requires C# knowledge to create small copy function and execute from your system. I will explain further if you are interested this way.

13
  • Thank you for this information, I am interested in using PnP because i will need the metadata as well. I am on Windows 7 SP1 and am in the middle of setting up PnP PowerShell now. Do I also need PowerShell Get? I appreciate your help! Commented May 26, 2017 at 19:35
  • I've got version 2.15.1705.0 on PnP Powershell installed - Will that video explain how to copy the library content + metadata to another library? btw, do you have paypal? haha I'll send you some $$ for helping me out, you can grab a drink or food on me! Commented May 26, 2017 at 19:51
  • Thanks for your offer. It's my pleasure helping through the community without charging. Mine is window 10 got this worked. I want you to setup environment first and test sample scripts to confirm PowerShell is working. Commented May 26, 2017 at 20:12
  • You're awesome man, thank you. I went to use the Connect_PnPOnline and got this error: Connect-PnPOnline : The remote server returned an error: (403) Forbidden.At line:1 cha + Connect-PnPOnline –Url cityofshoreline-admin.sharepoint.com –Credentials ... Commented May 26, 2017 at 20:16
  • Connect-Online -Url "cityofshoreline.sharepoint.com" -Credentials ... Commented May 26, 2017 at 20:18
0

Just want to add to Venkat's sync and copy option. Assuming you are very familiar with SharePoint designer and all the file names or Title names are unique and there are no folders, you could use a workflow to copy the metadata over to the new library.

  • create the new library to be identical as the old library including all the metadata columns

  • create a workflow on the new library to start when an item is created. In the workflow, add actions to set field values using values gotten from the old library. In those actions, filter by the file name or Title column

  • then sync both libraries to your computer

  • then copy files from the old library to the new one

  • after some minutes, all the metadata will be copied over

  • you can then delete the workflow on the new library

0

I saved the Source Document Library as a template with out the content included. Saving the template made sure that I had all columns and views.

After creating and adding the template to the site I wanted, I used "Site Content and Structure" under Site Settings to Copy the files over to the newly created Target Document Library. It also kept all the meta data. It wasn't a huge library, about 250 files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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