What is the correct syntax to exclude a folder's contents but not the folder itself
Fresh3 days ago
Mar 15, 202624971 viewsConfidence Score0%
0%
Problem
I have a powershell script that copies files from to and it excludes some files types. It excludes my csv files and web.config files fine, but it won't exclude the Log folder contents. This is my script, what is the correct syntax to exclude the files contents but not the folder itself?
Error Output
$exclude = @('Thumbs.db','*-Log.csv','web.config','Logs/*')
Get-ChildItem $source -Recurse -Exclude $exclude | Copy-Item -Destination {Join-Path $de…Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: What is the correct syntax to exclude a folder's contents but not the folder itself
Low Risk
You'll need to setup a second Array with the paths you want to avoid and then add a filter in the pipe. Here's some sample code:
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix