title: Scan txt file for multiple strings and save the following lines
body: <p>I have a problem that I am trying to solve, however, due to my non existing PowerShell knowledge it is proving to be harder than I hoped. So any help would be appreciated. </p>
  
  <p>The problem can be simplified as: </p>
  
  <ol>
  <li><p>Find a string in a txtfile </p></li>
  <li><p>Extract the information on the row after that string</p></li>
  <li><p>Store the information in a handle </p></li>
  <li><p>Find a second string in the txtfile and repeat the procedure</p></li>
  <li><p>Store both strings in a new file or delete everything else in the txt file. </p></li>
  </ol>
  
  <p>I am then trying to do this for approx 20k files. I would love to have the information under their keyword and comma delimited so that I can import them in other systems. </p>
  
  <p>My files look somewhat like the following </p>
  
  <pre class="lang-none prettyprint-override"><code>random words 
  that are unimportant 
  Keyword
  FirstlineofNumbersthatIwanttoExtract
  random words again that are unimportant 
  Secondkeyword
  SecondLineOfNumbersThatIWantToExtract
  end of the file 
  </code></pre>
  
  <p>All files are however not similar in terms of the row that the lines I want to extract are on. I would the output to be something like </p>
  
  <pre class="lang-none prettyprint-override"><code>Keyword, SecondKeyword
  FirstLineOfNumbersThatIWantToExtract, SecondLineOfNumbersThatIWantToExtract
  </code></pre>
  
  <p>And done. I got this far </p>
  
  <pre><code> [System.IO.DirectoryInfo]$folder = 'C:\users\xx\Desktop\mappcent3'
  
   foreach ($file in ($folder.EnumerateFiles())) {
       if ($file.Extension -eq '.txt') {
  
           $content = Get-Content $file
  
           $FirstRegex = 'KeyWordOne
      (.+)$'
  
      $First_output = "\1"
      $test = Select-String -Path $file.FullName -Pattern $FirstRegex 
  
    }
  }
  </code></pre>