powershell
powershell copied to clipboard
[BUG] Copy-PnPFile or Copy-PnPFolder not waiting for the all the operation
Notice
Many bugs reported are actually related to the PnP Framework which is used behind the scenes. Consider carefully where to report an issue:
- Are you using
Invoke-PnPSiteTemplateorGet-PnPSiteTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/pnp/pnpframework/issues. - Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
- If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/pnp/powershell/tree/master/src/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/pnp/pnpframework/issues
Reporting an Issue or Missing Feature
When using Copy-PnPFile or Copy-PnPFolder the command is returns as soon as the folder is created and all the files inside of it are being created in a background progress (this is without using the -NoWait argument)
Example:
Copy-PnPFile -SourceUrl $file["FileRef"] -TargetUrl $destinationFileUrl -Connection $connectionDestination -Force
This is on a folder, and the process end and keeps creating all the files inside of it
Expected behavior
The command should end when all the files inside of it (in the case of the folder) finish.
Actual behavior
As I can see as soon as the folder item is created the operation return
Steps to reproduce behavior
- Create a folder with multiple files in it
- Run the command for the copy
What is the version of the Cmdlet module you are running?
(you can retrieve this by executing Get-Module -Name "PnP.PowerShell" -ListAvailable)
Version 1.12.0
Which operating system/environment are you running PnP PowerShell on?
- [x] Windows
- [ ] Linux
- [ ] MacOS
- [ ] Azure Cloud Shell
- [ ] Azure Functions
- [ ] Other : please specify
Other stuff to mention is that Copy-PnPFile or Folder should be able to create the folders that it needs if is an item
For example: 'Documents/TestFolder/TestFile.txt' to 'Documents2/TestFolder' should create the folder "TestFolder" if it does not exist in the destination, this way we prevent to create a logic for the folders operation.
I feel like I accomplish this with a lower version of PnP, but I don't know if I set the operation on the folder