-
Notifications
You must be signed in to change notification settings - Fork 388
Description
Reporting an Issue or Missing Feature
https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/copy-pnpfile?view=sharepoint-ps states that
PS:>Copy-PnPFile -ServerRelativeUrl "/sites/project/Shared Documents/company.docx" -TargetServerRelativeLibrary "/sites/otherproject/Shared Documents"
will
Copies a file named company.docx located in a document library called Shared Documents in the site collection project to the Shared Documents library in the site collection otherproject. If a file named company.docx already exists, it won't perform the copy.
In https://github.com/pnp/powershell/blob/dev/src/Commands/Files/CopyFile.cs it seems that only folder is passed along CopyToOtherSiteCollection(sourceUri, targetUri);
and not the actual ref to the file meaning that the folder will always be passed?
This was changed in PnP-powershell in commit pnp/PnP-PowerShell@7f87352#diff-2a3f10f735507b7333a80eabec28831f5de366d962ad4637cff0326c3c80f718
Uri sourceUri = new Uri(currentContextUri, sourceFolder);
vs earlier SourceUrl.
This issue in the old repo says the same thing. pnp/PnP-PowerShell#2796
With this change my old script that copied files one by one (need to process each file individually so we at the same time can download and save metadata to replicate file by file in target location)
Expected behavior
When running
$fileRef = "/sites/Investment/SmallerTEst/General/3 test.docx"
$newTargetFolderUrl = "/sites/TargetTest2/Delade Dokument/General"
Copy-PnPFile -SourceUrl $fileRef -TargetUrl $newTargetFolderUrl -OverwriteIfAlreadyExists -Force
This should copy the file 3 test.docx to /sites/TargetTest2/Delade Dokument/General/3 test.docx
Actual behavior
This copies the whole "General" folder into /sites/TargetTest2/Delade Dokument/General/General (notice double General)
Steps to reproduce behavior
See above
What is the version of the Cmdlet module you are running?
ModuleType Version PreRelease Name PSEdition ExportedCommands
---------- ------- ---------- ---- --------- ----------------
Manifest 0.3.39 nightly PnP.PowerShell Core,Desk {Add-PnPClientSidePage, Add-PnPClientSidePageSection, Add-PnPCli…
Which operating system/environment are you running PnP PowerShell on?
- Windows
- Linux
- MacOS
- Azure Cloud Shell
- Azure Functions
- Other : please specify