• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    Powershell小技巧之复合筛选

    当你分析文本日志或筛选不通类型的信息时,你通常要使用 Where-Object。这里有一个通用脚本来说明复合筛选:

    # logical AND filter for ALL keywords 
    Get-Content -Path C:\windows\WindowsUpdate.log | 
     Where-Object { $_ -like '*successfully installed*' } | 
     Where-Object { $_ -like '*framework*' } | 
     Out-GridView
     
    # above example can also be written in one line 
    # by using the -and operator 
    # the resulting code is NOT faster, though, just harder to read 
    Get-Content -Path C:\windows\WindowsUpdate.log | 
     Where-Object { ($_ -like '*successfully installed*') -and ($_ -like '*framework*') } | 
     Out-GridView
     
    # logical -or (either condition is met) can only be applied in one line 
    Get-Content -Path C:\windows\WindowsUpdate.log | 
     Where-Object { ($_ -like '*successfully installed*') -or ($_ -like '*framework*') } | 
     Out-GridView
    
    您可能感兴趣的文章:
    • PowerShell中使用Get-ChildItem命令读取目录、文件列表使用例子和小技巧
    • Powershell小技巧之使用-F方法带入数据
    • Powershell小技巧之使用Copy-Item添加程序到开机启动
    • Powershell小技巧之通过EventLog查看近期电脑开机和关机时间
    • Powershell小技巧之使用Get-ChildItem得到指定扩展名文件
    上一篇:Powershell小技巧之使用Copy-Item添加程序到开机启动
    下一篇:Powershell小技巧之通过EventLog查看近期电脑开机和关机时间
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯 版权所有

    《增值电信业务经营许可证》 苏ICP备15040257号-8

    Powershell小技巧之复合筛选 Powershell,小,技巧,之,复合,