Hi,
Does this work for you?
$source = "C:\Data\ParentDir"
$destination = "E:\Storage"
$includes = "Numbers","Year"
Get-ChildItem -Path $source -Directory -Recurse | Where-Object {$_.Name -in $includes} |
ForEach-Object{copy-item $_.FullName -Destination $_.FullName.Replace($source, $destination) -Recurse -ErrorAction SilentlyContinue}
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.