For a simple example, suppose I have a Root folder with three folders in it; Folder1, Folder2 and Folder3. Each of these folders (including Root ) contains a bunch of files, including .pdb files. I want to use the PowerShell cmdlet Get-ChildItem to return all files to all folders (including Root ), except for the .pdb in folder 2. If I use:
Get-ChildItem -Path C:\Root -Recurse -Exclude *.pdb
Then I return all files without .pdb in all directories that are close to what I want. Therefore, I suggested that the following be achieved, what I want:
Get-ChildItem -Path C:\Root -Recurse -Exclude \*\\Folder2\\*.pdb
But this does not exclude any of the pdb files in Folder2 (or any other folders). I tried several options for the -Exclude filter, for example Folder2\\\*.pdb , but I can not get it to work. In fact, even using \*\\\*.pdb does nothing; .pdb files are excluded from any folders.
So it seems that wildcards cannot be used for directories, only file names, but I assume I'm just doing something wrong. I found this article explaining wildcard and range operators , but unfortunately does not discuss their use with directory names; file names only.
deadlydog
source share