I'm trying to find a way to use powershell to search for two different string matches in the same line, and then to output that string.
For example, I want to find all sentences in a text file that contain the word "dog" and "fence".
So it would hit and detect / output
Sentence 1: "The dog jumped over the fence"
But not match on:
Sentence 2: "The dog went to the park"
Sentence 3: "They painted their fence white"
Select-String will do this for a single pattern, but I can't seem to get it to work for two pattern matches in the same line.
This for example would detect two patterns, but all three sentences since it's looks for the pattern individually:
Select-String -Path C:\Logs -Pattern 'Dog','Fence'
I know there's easy ways to do this with grep and awk, but I was hoping to find a way to accomplish this in PowerShell.