0
votes

Currently, we have Document Libraries created in SharePoint Online and would like to move them using Powershell to its own Subsite. The reason we would like to move them is that we would like to keep the version history. Since we are dealing with 1000s of files, I would like to use Powershell to complete this task.

I am currently connecting to my SharePoint site using:

Connect-PnPOnline -Url "Sitename" -UseWebLogin

Here is where I need assistance. I am trying to use Move-PnPFolder but I am not sure how to write a command that would define the source, destination, and move of all files in the document library to a subsite that I have manually created.

1

1 Answers

0
votes

Here you need to mix of PnP and CSOM PS script... the normal way how we get the SharePoint list items... we need read the the list items then inside the foreach loop you need to call the below command : Move-PnPFolder -Folder 'Shared Documents/Reports/2016/Templates' -TargetFolder 'Shared Documents/Reports' Something like below :

foreach ($oneFolder in List. Folders) { Move-PnPFolder -Folder 'Shared Documents/Reports/2016/Templates' -TargetFolder 'Shared Documents/Reports' }

Note :

  • In the above command from the $oneFolder property you will get the source folder URL and you already know the target folder location.

  • This is just sample code to present the concept.