title: powershell trim - remove all characters after a string
body: <p>What would be the command to remove everything after a string (\test.something).
  I have information in a text file, but after the string there is like a 1000 lines of text that I don't want. how can I remove everything after and including the string.</p>
  
  <p>This is what I have - not working.  Thank you so much.</p>
  
  <pre><code>$file = get-item "C:\Temp\test.txt"
  
  (Get-Content $file) | ForEach {$_.TrimEnd("\test.something\")} | Set-Content $file
  </code></pre>