Powershell小技巧之复合筛选
当你分析文本日志或筛选不通类型的信息时,你通常要使用Where-Object。这里有一个通用脚本来说明复合筛选:
#logicalANDfilterforALLkeywords
Get-Content-PathC:\windows\WindowsUpdate.log|
Where-Object{$_-like'*successfullyinstalled*'}|
Where-Object{$_-like'*framework*'}|
Out-GridView
#aboveexamplecanalsobewritteninoneline
#byusingthe-andoperator
#theresultingcodeisNOTfaster,though,justhardertoread
Get-Content-PathC:\windows\WindowsUpdate.log|
Where-Object{($_-like'*successfullyinstalled*')-and($_-like'*framework*')}|
Out-GridView
#logical-or(eitherconditionismet)canonlybeappliedinoneline
Get-Content-PathC:\windows\WindowsUpdate.log|
Where-Object{($_-like'*successfullyinstalled*')-or($_-like'*framework*')}|
Out-GridView
热门推荐
1 带猫的祝福语简短
6 七十年祝福语简短
10 女神节祝福语简短创意
11 新娘生孩子祝福语简短
12 男孩中考蛋糕祝福语简短
13 蛋糕开学祝福语 简短独特
14 最佳元旦祝福语简短学校
15 下午微信祝福语简短
16 初四祝福语简短霸气
17 祝福语简短唯美老师的话
18 送弟妹住院祝福语简短