Search for 2 occurrences in powershell

0

How can I do to find 2 occurrences together in a determination file using powershell?

$p = @("string1","string2")
get-content C:\log.txt | Select-String -Pattern $p 

Above, the expression returns me the occurrences that have one OR string the other. It's not what I want, I want to have one E string the other.

What are the ways to do this?

    
asked by anonymous 30.10.2017 / 14:54

1 answer

1

You can do it like this

get-content C:\log.txt | Select-String -Pattern "string1" |  Select-String -Pattern "string2"

I do not know if there is a better way

    
23.01.2018 / 17:32