8,330 questions
You can use the -Exclude switch Copy-Item -Recurse -Force -Path "C:\ProgramData\SourceDirectory*" -Destination "D:\TargetDir" -Exclude "*.exe"
hth Marcin
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, I have a directory, let's say C:\ProgramData\SourceDirectory SourceDirectory contains several sub-folders and .exe files. Copy-Item -Force -Recurse "C:\ProgramData\SourceDirectory" -Destination D:\TargetDir I want to include only the sub-folders in the SourceDirectory and exclude any .exe files in this SourceDirectory.
You can use the -Exclude switch Copy-Item -Recurse -Force -Path "C:\ProgramData\SourceDirectory*" -Destination "D:\TargetDir" -Exclude "*.exe"
hth Marcin