I am using Powershell v 2.0. and copying files and directories from one location to another. I am using a string[] to filter out file types and also need to filter out a dir
The -Exclude
parameter is pretty broken. I would recommend you to filter directories that you don't want using Where-Object (?{})
. For instance:
$exclude = @('*.cs', '*.csproj', '*.pdb')
$items = Get-ChildItem $parentPath -Recurse -Exclude $exclude | ?{ $_.fullname -notmatch "\\obj\\?" }
P.S.: Word of warning – don't even think about using -Exclude
on Copy-Item
itself.