代码之家  ›  专栏  ›  技术社区  ›  Ranadip Dutta

过滤器中的通配符搜索

  •  4
  • Ranadip Dutta  · 技术社区  · 8 年前

    这将产生适当的结果

    Get-WmiObject -Class Win32_Service -Filter "Name = 'vss'"
    

    如何在过滤器内进行通配符搜索,而不将其传输到where条件,例如:

    Get-WmiObject -Class Win32_Service -Filter "Name='v*'"
    
    Get-WmiObject -Class Win32_Service -Filter "Name='*v*'"
    
    Get-WmiObject -Class Win32_Service -Filter "Name='v'"
    
    Get-WmiObject -Class Win32_Service -Filter "Name like 'v*'"
    
    1 回复  |  直到 8 年前
        1
  •  7
  •   the_sw    8 年前
    Get-WmiObject -Class Win32_Service -Filter "name LIKE 'vss%'"
    

    它使用WQL进行过滤(%为通配符)

    最终被作为

    Get-WmiObject -Query "Select * From win32_service Where name Like 'vss%'"