Share via


Selecting Multiple Strings with the SELECT-STRING command in PowerShell

Question

Monday, May 8, 2017 6:24 PM

I am able to search through a log file for one string, but I want to search the file for a handful of strings.  How would I update the command below to search for string1, string2, and string3?

 select-string "string1" | Out-File C:\parsed.csv

All replies (2)

Tuesday, May 9, 2017 8:42 AM âś…Answered | 2 votes

Hi Nick,

Try:

Select-String -pattern "string1", "string2", "string3"

Select-String [-Pattern] <String[]>

https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.utility/select-string?f=255&MSPPError=-2147217396

Best regards,

Andy

Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].


Tuesday, May 9, 2017 7:57 AM

Hi Nick,

According to your description, your issue is more related about PowerShell. And this forum is discussing and asking questions about the Windows Form and ClickOnce,  I will move this thread to corresponding forum: PowerShell Forum for dedicated information. You will get a more professional support from there, thank you for your understanding.

Best Regards,

Stanly

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].