title: How to use Powershell to return both filename and the matched text in the file
body: <p>I have a list of pre-processed log files collected from mutliple servers. They are in CSV format and the content of the log files is in the format:</p>
  
  <p>Date,Time,Value1,Value2,Value3</p>
  
  <p>I would like to have a single file consolidated with the information from the filename of the log file(which has the server name) and all the date and time when Value1 exceed certain value in the log files for futher analysis. In other words, I would like the expected output to be:</p>
  
  <p>Filename1,2011/10/01,12:00:00.256,2345,210,0
  Filename1,2011/10/05,13:45:36.321,2666,209,0
  Filename5,2011/10/09,09:08:02.111,2100,180,0
  Filename20,2011/10/15,17:09:33.256,3019,109,0
  ...</p>
  
  <p>I have tried to use Powershell + regular expression to extract the information. However, I can only get the line containing the value I want and the filename or only the Date, time and Value1. The PowerShell scripts are:</p>
  
  <p>select-string -path "C:\Server\Logs*.csv" -pattern "([0-9]{4}/[0-9]{1,2}/[0-9]{1,2}),([0-9]{2}:[0-9]{2}:[0-9]{2}).[0-9]{3},([2-9][0-9]{3})" | select-object -property filename, linenumber, line | export-csv -path highload2.csv</p>
  
  <p>select-string -path "C:\Server\Logs*.csv" -pattern "([0-9]{4}/[0-9]{1,2}/[0-9]{1,2}),([0-9]{2}:[0-9]{2}:[0-9]{2}).[0-9]{3},([2-9][0-9]{3})" | select-object -expand Matches | Foreach {$<em>.Groups[1].Value, $</em>.Groups[2].Value, $_.Groups[3].Value} </p>
  
  <p>Is there a way to get the result that I need?</p>
  
  <p>Thanks,</p>