powershell icon indicating copy to clipboard operation
powershell copied to clipboard

Copy-PnpFile -SkipSourceFolderName Return

Open jreinhardtproarch opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe. The problem is that Copy-PnpFile no longer has the functionality to copy a folder's contents into the root of another location (whether document library, subfolder, and regardless of whether its in the same site collection or not).

Describe the solution you'd like We'd like to see the parameter -SkipSourceFolderName return. We don't know why it was removed, but this module indicates "WARNING: Parameter 'SkipSourceFolderName' is obsolete. This parameter is obsolete and has no effect currently."

Describe alternatives you've considered We are struggling to find a solution. One alternative would involve manually writing code to get all files and folders in a given subfolder, run Copy-PnpFile on each file and then repeat for each subfolder with its contents. It's possibly doable with the current cmdlet, but less effective.

Additional context We need to migrate the entire contents of a subfolder of a single document library to a new site collection created based on a template site, and also grant permissions to this newly created site collection. The document migration is a part of that overall algorithm.

jreinhardtproarch avatar Jun 07 '22 19:06 jreinhardtproarch

Maybe you can use the Copy-PnPFolder , it will copy the folder along with the files inside that ?

gautamdsheth avatar Jun 08 '22 10:06 gautamdsheth

@gautamdsheth, thank you. Copy-PnPFolder is actually an alias of Copy-PnpFile so that is practically the same. Problem is not copying the files and subfolders. The issue is that it copies the folder itself into the destination location, when what is really needed is to copy the contents of the folder into the destination location.

If I were working with Windows files, the following command would do the needful:

Copy /originalfolder/. /newfolder/

The result would be all files in /originalfolder being in /newfolder. However, with Copy-PnpFile/Copy-PnPFolder, the outcome is that you end up with the following path created /newfolder/originalfolder/.

jreinhardtproarch avatar Jun 08 '22 17:06 jreinhardtproarch

Aghh. Just found this issue recently myself. Want to copy the contents of the folder in SharePoint online to another location but not the top level folder itself....

Found the switch -SkipSourceFolderName on to find out it's obsolete....

TheRealStriff avatar Jan 23 '23 00:01 TheRealStriff