Powershell小技巧之復合篩選
更新時間:2014年09月05日 09:56:37 投稿:hebedich
這篇文章主要介紹了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
相關文章
windows Powershell 快速編輯模式和標準模式
powershell控制臺有兩種模式,一個是快速編輯模式,一個是標準模式。2014-08-08
PowerShell中使用Filter來創(chuàng)建管道輸入函數(shù)
這篇文章主要介紹了PowerShell中使用Filter來創(chuàng)建管道輸入函數(shù),Filter創(chuàng)建的函數(shù)跟Function創(chuàng)建的函數(shù),在本質上是一樣的,需要的朋友可以參考下2014-07-07
PowerShell中Job相關命令及并行執(zhí)行任務詳解
這篇文章主要給大家介紹了關于PowerShell中Job相關命令及并行執(zhí)行任務的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧。2018-03-03
PowerShell中獲取Windows系統(tǒng)序列號的腳本分享
這篇文章主要介紹了PowerShell中獲取Windows系統(tǒng)序列號的腳本分享,本文方法是讀取注冊表中的信息,然后處理成序列號輸出,需要的朋友可以參考下2014-11-11
PowerShell函數(shù)中限制數(shù)組參數(shù)個數(shù)的例子
這篇文章主要介紹了PowerShell中限制函數(shù)的數(shù)組參數(shù)個數(shù)的例子,可以控制數(shù)組的參數(shù)個數(shù)在指定范圍內,需要的朋友可以參考下2014-07-07

