當(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
標(biāo)簽:襄陽 臨汾 疫苗接種 汕頭 天水 喀什 湘潭 南昌
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Powershell小技巧之復(fù)合篩選》,本文關(guān)鍵詞 Powershell,小,技巧,之,復(fù)合,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。