title: Use PowerShell to strip data
body: <p>I have a file that contains data such as:
  <code>
  ABC|LT293012|293012
  ABC|LT9281749|9281749
  ABC|LT12345|12345</code></p>
  
  <p>I want to create a comma-delimited string out of it that looks like:</p>
  
  <pre><code>LT293012,LT9281749,LT12345
  </code></pre>
  
  <p>In other words, everything (including) the first | and everything (including) after the second | need to be stripped.</p>
  
  <p>I've used:</p>
  
  <pre><code>$list=(Get-Content $file).replace("ABC`|", "") -join "," 
  </code></pre>
  
  <p>but that does not strip the second | and data</p>
  
  <p>Although 'ABC' should always be a static value if it is easier to just leave anything surrounded by the pipe character, that would be fine. There will ALWAYS be three elements to the value.</p>
  
  <p>I suppose I could read in the file using ConvertFrom-CSV, add headers, and pipe that into a select, pulling only the middle element, but there is probably an easier way of doing it.</p>
  
  <p><strong>EDIT</strong>: I forgot a key piece. Each element needs to be enclosed in a single quote so that the final output is <code>'LT293012','LT9281749','LT12345'</code></p>