Powershell小技巧之復(fù)合篩選
當(dāng)你分析文本日志或篩選不通類型的信息時(shí),你通常要使用 Where-Object。這里有一個(gè)通用腳本來(lái)說(shuō)明復(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小技巧之同時(shí)使用可選強(qiáng)制參數(shù)
本文主要講訴了在腳本函數(shù)中讓可選參數(shù)和強(qiáng)制參數(shù)必須同時(shí)使用,有需要的朋友可以參考下。2014-09-09
如何防范PowerShell代碼注入漏洞繞過(guò)受限語(yǔ)言模式
這篇文章主要介紹了如何防范PowerShell代碼注入漏洞繞過(guò)受限語(yǔ)言模式的相關(guān)資料,需要的朋友可以參考下2017-10-10
windows Powershell 快速編輯模式和標(biāo)準(zhǔn)模式
powershell控制臺(tái)有兩種模式,一個(gè)是快速編輯模式,一個(gè)是標(biāo)準(zhǔn)模式。2014-08-08
PowerShell中使用Filter來(lái)創(chuàng)建管道輸入函數(shù)
這篇文章主要介紹了PowerShell中使用Filter來(lái)創(chuàng)建管道輸入函數(shù),Filter創(chuàng)建的函數(shù)跟Function創(chuàng)建的函數(shù),在本質(zhì)上是一樣的,需要的朋友可以參考下2014-07-07
Powershell小技巧之創(chuàng)建一個(gè)新對(duì)象
這篇文章主要介紹了使用Powershell簡(jiǎn)單有效的創(chuàng)建一個(gè)自定義對(duì)象的方法,非常的簡(jiǎn)單,需要的朋友可以參考下2014-10-10
PowerShell中Job相關(guān)命令及并行執(zhí)行任務(wù)詳解
這篇文章主要給大家介紹了關(guān)于PowerShell中Job相關(guān)命令及并行執(zhí)行任務(wù)的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2018-03-03
PowerShell中獲取Windows系統(tǒng)序列號(hào)的腳本分享
這篇文章主要介紹了PowerShell中獲取Windows系統(tǒng)序列號(hào)的腳本分享,本文方法是讀取注冊(cè)表中的信息,然后處理成序列號(hào)輸出,需要的朋友可以參考下2014-11-11
PowerShell函數(shù)中限制數(shù)組參數(shù)個(gè)數(shù)的例子
這篇文章主要介紹了PowerShell中限制函數(shù)的數(shù)組參數(shù)個(gè)數(shù)的例子,可以控制數(shù)組的參數(shù)個(gè)數(shù)在指定范圍內(nèi),需要的朋友可以參考下2014-07-07

