4

I'd like to be able to do

gci -filter *.ps1,*.cs,*.sql

but that syntax isn't supported.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Scott Weinstein
  • 18,890
  • 14
  • 78
  • 115

2 Answers2

8

Use -Include which takes an array, instead of -Filter. Note that you have to use * as the path when using -Include:

Get-ChildItem * -Include *.ps1,*.cs,*.sql
Julien Lebosquain
  • 40,639
  • 8
  • 105
  • 117
1

With v3, can do gci -file "*.ps1","*.txt"

noam
  • 1,914
  • 2
  • 20
  • 26
  • 1
    This too wants the path to be the current directory, but push-location seems to offer a viable workaround. I'm beginning to suspect that -file performs more like -include as opposed to the faster -filter. – noam Dec 07 '12 at 00:15
  • I posted this as a separate qn here http://stackoverflow.com/questions/13770262/is-get-childitems-new-file-parameter-fast-like-filter-or-slow-like-include – noam Dec 07 '12 at 20:16
  • 2
    `-file` is a switch parameter and doesn't accept values! "*.ps1","*.txt" are passed as values for parameter `-path`. Your command is equivalent to do `gci -path "*.exe","*.xml"` but only excude eventualy directory with name endinf with `.ps1` or `.txt` – CB. Dec 07 '12 at 21:35