Windows Vista Forums

What expressions can you specify in the -filter param for dir

  1. #1


    Bob Landau Guest

    What expressions can you specify in the -filter param for dir

    I'm trying to better understand what expressions can be used in the -filter
    parameter for the get-childitem cmdlet.

    I've looked in the following helpfiles

    get-childitem
    about_wildcards
    about_providers
    < and a few others>

    The documentation for get-childitem states the syntax and use of wildcards
    for the filter parameter is dependant on the provider.

    The documentation for about_wildcards states that besides the well know * ?
    wildcards you can use ranges and sets.

    The documentation for about_provider did not address this.

    Below is what I've found by experimentation


    c:> cd \windows\system32
    c:\windows\system32>: get-childitem -filter a?* # works as expected

    c:\windows\system32>: get-childitem [a-b]?* # works as expected

    c:\windows\system32>: get-childitem -filter [a-b]?* # doesn't work


    Does the "provider" not provide this type of wildcard? Bug?


    How are you suppose to know what you can use; trial and error?

    I'm hoping that someone can point to some documentation that shows what
    syntax each provider can use in the -filter parameter

    thanks again

    bob

      My System SpecsSystem Spec

  2.   


  3. #2


    Kiron Guest

    Re: What expressions can you specify in the -filter param for dir

    Get-ChildItem's -filter, -include, -exclude accept wildcards '*,?', no regex
    patterns nor ranges. Ranges are passed to the -path parameter.

    get-childitem -path [a-b]?* # should work

    --
    Kiron


      My System SpecsSystem Spec

  4. #3


    Bob Landau Guest

    Re: What expressions can you specify in the -filter param for dir

    I appreciate the response however this is not what I've found to be the case.
    From what the doc state

    -include, -exclude

    are both process by Powershell itself so are capable of handling regex.

    -filter however is an escape mechanism which passes the processing to the
    provider.

    Try this

    c:\windows\system32> get-childitem *.* -include [a-z]?*.dll -exclude
    [abcdefghijklmn]?*.*


    This works as expected. The problem evidently is no one other than a few
    Microsoft developers and possibly testors know absolultely what is allowed
    for the filter parameter.

    Oh well, I'm sure the doc's well get better

    bob

    "Kiron" wrote:

    > Get-ChildItem's -filter, -include, -exclude accept wildcards '*,?', no regex
    > patterns nor ranges. Ranges are passed to the -path parameter.
    >
    > get-childitem -path [a-b]?* # should work
    >
    > --
    > Kiron
    >

      My System SpecsSystem Spec


What expressions can you specify in the -filter param for dir
Similar Threads
Thread Forum
Filter Multicast & Filter Internet NAT Redirection settings question Vista security
Junk Filter doesn't filter Live Mail
Using param with InvokeReturnAsIs PowerShell
param VS dotsourcing PowerShell
help. Digital filter? how to de-filter? USB audio device Vista hardware & devices