views:

35

answers:

1

I would like to search for more than one strings of the files in directory however the select-string -pattern didn't help. Could anyone show me how to do it. Example: Search all files in C:\Logs that contains the words VendorEnquiry and Failed and Logtime about 11:30 am. Structure of files may different e.g different tag names etc..

eg. ..<methodException>VendorEnquiry</methodException> ... <logTime>13/10/2010T11:30:04 am</logTime> ...
<status>Failed</status> 

eg. ..<serviceMethodException>VendorEnquiry</serviceMethodException> ... <logTime>13/10/2010</logTime> ...<serviceStatus>Failed</serviceStatus> 

Thanks.

A: 

How about using regex in powershell?

http://powershell.com/cs/blogs/ebook/archive/2009/03/30/chapter-13-text-and-regular-expressions.aspx

XML parsing may be a better solution. http://thepowershellguy.com/blogs/posh/archive/2007/12/30/processing-xml-with-powershell.aspx

stackunderflow
I don't want to use xml parsing caused very slow performance for huge log files. I want something that fast. Regex is good however I don't know how I can write the expression that search in the file where there is a word VendorEnquiry and Failed exists.
Thomas

related questions