Hey everyone, I'm using Windows 10 Pro and I have a PowerShell script that I set up a while ago to back up a legacy program's directory structure since it doesn't have its own backup option. I run this script every day with the Windows Task Scheduler. Here's what the action looks like: program/script is Powershell.exe, and the arguments are -ExecutionPolicy Bypass -WindowStyle Hidden C:PEMcopyPEMscript.ps1. The script content is: `Copy-Item -Path C:PEM*.* -Destination "D:foofoo2PEM Backup" -Force -Recurse`. However, I'm confused because it seems to be generating only a single file in the foo2 directory, instead of the entire folder structure I thought the '-Recurse' flag would provide. Can anyone help me figure out what I might be missing? Thanks!
1 Answer
The issue is actually with the wildcard you're using. Instead of `C:PEM*.*`, which specifies files using an old method that only matches the 8.3 filename format, you should just use `C:PEM*`. The corrected command should be: `Copy-Item -Path C:PEM* -Destination "D:foofoo2PEM Backup" -Force -Recurse`. This way, it will copy everything in the directory recursively without missing anything. Let me know if that helps!

I tried the modification and it works! Thank you. What I still don't understand is, the source directory contains a number of files with extensions. It seems that the old `*.*` wildcard did not even copy those.