title: Parse multiple text files line by line but only the lines before a specific match
body: <p>I'm working on a large number of log files and I would like to parse all the lines before a specific match in each file.</p>
  <p>Files look like this :</p>
  <pre><code>04/14/2022 02:07:19 SLK 1234 12345 86177500 ERROR - UPDSERVS: SERVICE :SOFTWARESERVICE - IS NOT INSTALLED
  04/14/2022 02:07:58 SLK 1234 12345 86216625 ERROR - Bin File Creation and Dump Raw Output Disabled
  04/14/2022 02:08:01 SLK 1234 4321 86219734 BADERROR(3328:1416) Default PROCESS TIMING THRESHOLD 10
  04/14/2022 02:08:08 SLK 1234 4321 86226078 ETHERNET(4264:5628) USER 1 Cluster 1 ID 00EQ3G038651
  04/14/2022 02:08:08 SLK 1234 4321 86226078 ETHERNET(4264:5628) USER 2 CLuster 2 ID 00EQ3G026434
  00000000-0000-0000-0000-000000000664 Error 2022-04-13T02:09:07+02:00 LegacyErrorLog SYSERR(4320:4404) ERRORLOG.CPP(606) sscmd(5812:1) KEYINPUT.CPP(209) Command: MANUAL ROLLOVER
  00000000-0000-0000-0000-000000000649 Error 2022-04-13T02:09:07+02:00 LegacyErrorLog SYSERR(4320:4404) ERRORLOG.CPP(606) Closed the current active Error Log due to: Manual rollover.
  </code></pre>
  <p>And I want all the n lines (from all the files) before the pattern &quot;Command: MANUAL ROLLOVER&quot; excluding that line, then parse the data in an Excel spreadsheet like this :</p>
  <pre><code>Client ID ||     Date     ||   Time    || Error code|| Detail
  SLK-1234      04/14/2022     02:07:19     12345        86177500 ERROR - UPDSERVS: SERVICE :SOFTWARESERVICE - IS NOT INSTALLED
  SLK-1234      04/14/2022     02:07:19     12345        86216625 ERROR - Bin File Creation and Dump Raw Output Disabled
  SLK-1234      04/14/2022     02:07:19      4321        86219734 BADERROR(3328:1416) Default PROCESS TIMING THRESHOLD 10
  
  </code></pre>
  <p>I &quot;think&quot; I got the first part correct with this code :</p>
  <pre><code>$move = &quot;X:\New\test\Output&quot;
  $root = &quot;X:\New\test&quot;
  $files = Get-ChildItem -Path $root -Filter *.*
  
  $Results = foreach( $File in $Files ){
  $location = $root+&quot;\&quot;+$file
  
      $s = Select-String -Path &quot;$location&quot; -Pattern &quot;Command: ROLLOVER ERRORLOG&quot; -Context ?,0 |
          Foreach-Object { $_.Line,$_.Context.PreContext[0].Trim()}
  </code></pre>
  <p>But I've rarely extracted to Excel so I don't know How I could achieve the rest :/.</p>