How to exclude list of items from Get-ChildItem result in powershell?

This works too:

get-childitem $path -recurse -exclude *.cs,*.tt,*.xaml,*.csproj,
  *.sln,*.xml,*.cmd,*.txt

Note that -include only works with -recurse or a wildcard in the path. (actually it works all the time in 6.1 pre 2)

Also note that using both -exclude and -filter will not list anything, without -recurse or a wildcard in the path.

-include and -literalpath also seem problematic in PS 5.

There’s also a bug with -include and -exclude with the path at the root “”, that displays nothing. In unix it gives an error.

Excluding a directory like “foo3” (not the full path) is challenging. It doesn’t seem to work with -recurse or -filter. You can pipe to a 2nd get-childitem.

get-childitem -exclude foo3 | get-childitem -recurse -filter file*

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)