title: Using PowerShell to remove lines from a text file if it contains a string
body: <p>I am trying to remove all the lines from a text file that contains a partial string using the below PowerShell code:</p>
  
  <pre><code> Get-Content C:\new\temp_*.txt | Select-String -pattern "H|159" -notmatch | Out-File C:\new\newfile.txt
  </code></pre>
  
  <p>The actual string is <code>H|159|28-05-2005|508|xxx</code>, it repeats in the file multiple times, and I am trying to match only the first part as specified above. Is that correct? Currently I am getting empty as output.</p>
  
  <p>Am I missing something?</p>