-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Copy-PnPFile only copies folders even if file is specified #126
Comments
Hej Patrik, The cmdlet used the CSOM version of a copyjob behind the scenes but it didn't specify a file name if provided. I have updated both Copy-PnPFile and Move-PnPFile cmdlets to use an updated version of the code to copy the files. I also updated the documentation at https://pnp.github.io/powershell accordingly. Some of the parameters have been renamed, but aliases have been provided where appropriate. |
Thanks for the quick response @erwinvanhunen. It seems the sleep added in RestHelper checking on jobstatus is a bit over-zealous. Right now all copies with the nightly build take at least 5-10 sec compared to the avg of 0-2 with the legacy PnP-PowerShell. This would bump my total runtime of the script to over 14 full days. How about perhaps either I guess A is the easiest fix that would let me actually use the cmdlets again. Thoughts? Let me know if you are pressed for time and I could take the time to set up a dev env for pnp-powershell to create a simple PR (it will just take me some time since I never develop cmdlets :)) Ref commit: 0ed8d91#comments is |
Fair feedback. We updated the cmdlets. Both Copy-PnPFile and Move-PnPFile now support a -NoWait parameter which will return the cmdlet immediately after the first progress poll. The cmdlet will then return a job object which can be used in combination with Receive-PnPCopyMoveJobStatus to retrieve the job status. See the documentation which will be updated tomorrow after the nightly build (or check the repo now). It will be available in build 1.1.3-nightly. |
Reporting an Issue or Missing Feature
https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/copy-pnpfile?view=sharepoint-ps states that
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
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
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?
Which operating system/environment are you running PnP PowerShell on?
The text was updated successfully, but these errors were encountered: