Powershell小技巧之复合筛选
2014-09-05 09:56
696 查看
当你分析文本日志或筛选不通类型的信息时,你通常要使用 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小技巧之获取TCP响应(类Telnet)
- Powershell小技巧之删除不规则字符
- PowerShell小技巧之从函数中返回多个值
- PowerShell小技巧之观察UNC路径
- Powershell小技巧之创建一个新对象
- Win10小技巧:如何将在此处打开命令改为CMD或Powershell?
- Powershell小技巧之查看安装的.Net framework版本信息
- PowerShell小技巧之启动远程桌面连接
- Powershell小技巧之获取字符串的行数
- Lync 小技巧-37-Lync PowerShell-打不开
- PowerShell入门教程之高效使用PowerShell交互式运行环境的几个小技巧
- Powershell小技巧之非相同域或信任域也能远程
- PowerShell小技巧之发送TCP请求
- Powershell小技巧--远程对比服务配置
- Powershell小技巧之系统运行时间
- PowerShell小技巧之配置机器的静态IP
- PowerShell小技巧之查找获取注册表路径
- 子报表复合条件筛选 兼答rockyvan
- Exchange 2013 管理小技巧一-批量启用邮箱用户-利用Powershell
- Powershell小技巧之使用WMI工具