【问题标题】:How to make filter for symbol - in PowerShell如何为符号制作过滤器 - 在 PowerShell 中
【发布时间】:2018-08-30 13:25:08
【问题描述】:

如何在 PowerShell 中为符号制作过滤器

Get-ChildItem -Include *-* 

如果我的文件或文件夹的名称类似于

Test1-DEV

Test2-测试

Test3-Staging

【问题讨论】:

    标签: powershell wildcard


    【解决方案1】:

    使用-Path(默认参数):

    Get-ChildItem -Path *-* 
    

    或者,如果您在子目录中搜索,请将-Recurse 参数与-Include 结合使用。

    来自Get-Help Get-ChildItem

    -Include <String[]>
    
    Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value of this
    parameter qualifies the Path parameter. Enter a path element or pattern, such as *.txt. Wildcards are
    permitted.
    
    The Include parameter is effective only when the command includes the Recurse parameter or the path leads to
    the contents of a directory, such as C:\Windows\*, where the wildcard character specifies the contents of the
    C:\Windows directory.
    
    Required?                    false
    Position?                    named
    Default value                None
    Accept pipeline input?       False
    Accept wildcard characters?  false
    

    【讨论】:

    • It helps to link to the documentation 并解释为什么您正在做的事情可以解决问题。
    • 似乎适合我的任务。 PowerSheel 3. 是的,我尝试将 -include 与 -Directory 结合使用。
    • @justromagod 很高兴我能帮上忙,如果有帮助,我可以鼓励你accept an answer,我注意到你有很多帖子没有被接受的答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-31
    • 2019-08-10
    • 1970-01-01
    • 2020-07-01
    • 2021-04-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多