Forum Discussion
Copy-PnPFile Not Working Value cannot be null.\r\nParameter name: Null value for source item at
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, please let me know what can be done to make it work.
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
3 Replies
- MarceloMendesCopper Contributor
I've had the same issue and it turns out that you can use it for the root folder, but it contains a hidden forms folder that is the default folder MS uses for Microsoft Forms for that Sharepoint site. When copying at root folder level, you have to make sure you're excluding the forms folder like
$folder.name -ne "Forms"
AshMSport Is there any required column in destination site library for which you are passing null values from source site library?
If yes, try removing required settings from column for time being while copying files using PowerShell.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- AshMSportCopper ContributorThere are no required fields.