Can't copy folders

Sorry for the basic question but I’m stumped. Everything else is working but I can’t get the script to copy a folder.

Originally I had it doing something more complicated but for now I’m just trying the very basic.

Copy-File -Path “$dirSupportFiles*.*” -Destination “C:\Apps” -recurse

in my SupportFiles directory I have a folder called “Avaya” and a document called “batman.txt”. Only “batman.txt” gets copied over.

So I ended up abandoning Copy-File and instead just used Copy-Item.

<code>       
$User = $($CurrentLoggedOnUserSession.Username)
Copy-Item &quot;$dirSupportFiles\*&quot; &quot;C:\Users\$User\Appdata\Roaming&quot; -Recurse
</code>

Was doing some searching and found this post. I have the same problems. At the same time the copy to $evnCommonPrograms was dumping to the root of C for some reason as well.

Here’s what I did. The folder name is ‘Home Care Access’ and gets copied to the Public Desktop:

Copy-File -Path “$dirFiles\Desktop Folders\Home Care Access” -Destination $envCommonDesktop -Recurse

1 Like

I had the same problem.
The trick is to use just * instead of *.*
So,

Copy-File -Path “$dirSupportFiles*” -Destination “C:\Apps” -recurse

will copy the folders also.
(Keep in mind that powershell is working with objects, not with strings like DOS.)