Forum Discussion
Copy-PnPFile Not Working Value cannot be null.\r\nParameter name: Null value for source item at
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"
I like the sound of this, but I can't figure out how to use your exclusion in the syntax for this command.
(Sorry, I'm brand new to Powershell, and just trying to use it for the first time to migrate some Sharepoint sites.)
For example, how would I incorporate $folder.name -ne "Forms" into the following example?
#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing"
$SourceFolderURL = "/sites/Marketing/Shared Documents"
$TargetFolderURL = "/sites/Purchase/Shared Documents"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Copy All Files and Folders between source and target folders
Copy-PnPFile -SourceUrl $SourceFolderURL -TargetUrl $TargetFolderURL -Force -OverwriteIfAlreadyExists