Powershell小技巧之復(fù)合篩選
更新時間:2014年09月05日 09:56:37 投稿:hebedich
這篇文章主要介紹了Powershell復(fù)合篩選的小技巧 ,需要的朋友可以參考下
當(dāng)你分析文本日志或篩選不通類型的信息時,你通常要使用 Where-Object。這里有一個通用腳本來說明復(fù)合篩選:
# 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
相關(guān)文章
PowerShell小技巧之同時使用可選強(qiáng)制參數(shù)
本文主要講訴了在腳本函數(shù)中讓可選參數(shù)和強(qiáng)制參數(shù)必須同時使用,有需要的朋友可以參考下。2014-09-09
windows Powershell 快速編輯模式和標(biāo)準(zhǔn)模式
powershell控制臺有兩種模式,一個是快速編輯模式,一個是標(biāo)準(zhǔn)模式。2014-08-08
PowerShell中使用Filter來創(chuàng)建管道輸入函數(shù)
這篇文章主要介紹了PowerShell中使用Filter來創(chuàng)建管道輸入函數(shù),Filter創(chuàng)建的函數(shù)跟Function創(chuàng)建的函數(shù),在本質(zhì)上是一樣的,需要的朋友可以參考下2014-07-07
PowerShell中Job相關(guān)命令及并行執(zhí)行任務(wù)詳解
這篇文章主要給大家介紹了關(guān)于PowerShell中Job相關(guān)命令及并行執(zhí)行任務(wù)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。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ù)在指定范圍內(nèi),需要的朋友可以參考下2014-07-07

