I'm tying to use Copy-PnPFile command to copy all files and folders from site collection A document library to another site collection B/folder but it's not working. Following is the command I'm using:
Copy-PnPFile -SourceUrl "/sites/AshTest/Docs" -TargetUrl "/sites/ADM-AshTest/TestDocs/Docs" -Force
Error:
Copy-PnPFile : {"odata.error":{"code":"-2147467261, System.ArgumentNullException","message":{"lang":"en-US","value":"Value cannot be null.\r\nParameter name: Null value for source item at
https://tenant.sharepoint.com/sites/AshTest/Docs"}}}
At line:1 char:1
Copy-PnPFile -SourceUrl "/sites/AshTest/Docs" -TargetUrl "/sites/ADM- ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : WriteError: (:) [Copy-PnPFile], HttpRequestException
FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Files.CopyFile
Please let me know what can be done to make it work.
CodePudding user response:
According to my research, Copy-PnPFile
does not work on the root folder of a library.
Here is a similar issue for reference: https://github.com/pnp/powershell/issues/410
===================================
If the answer is helpful, please click "√" on the left panel of the answer and kindly upvote it.