'Powershell - Copy folders alongside files in each sub folder

I have the following structure

- folder1
 - file1
 - folder2
   - file2
 - folder3
   - file3
   - file4
   - file5
- folder4
 - file6
 - folder5
   - file7
 - folder5
   - file8

I am trying to copy all the file and the folders to a different directory but what happens is that the folders (folder 1, 2, 3) are copied; within folder 3 are all the corresponding files (file3, file4, and file5) but file1 and file2 which files in folder 1 and folder 2 are left out in the copy.

Below is the powershell code snippet i use:

Copy-Item -Path c:\folder1\folder2\folder3\* -Destination d:\ -Recurse -Verbose



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source