How do I use square brackets in a wildcard pattern in PowerShell Get-ChildItem?

后端 未结 2 1949
有刺的猬
有刺的猬 2021-01-07 03:22

I want to list all files ending with some text in square brackets.

But neither Get-ChildItem *[* nor Get-ChildItem *`[* nor Get-Child

2条回答
  •  别那么骄傲
    2021-01-07 03:54

    You have to use the -Filter Parameter correct. When you don't specify the Parameter, like you did in your examples, it will assume you want to use the first Parameter (in this case -Path, Ref. Get-ChildItem Doc).

    Try this instead:

    Get-ChildItem -Filter "*`[*"
    

    This found the file ad.a[s] for me.

    You can also change the filter to this:

    Get-ChildItem -Filter "*`[*`]"
    

    to expand it for the closing bracket.

提交回复
热议问题