title: Extracting a pattern from output of an external command in Powershell
body: <p>For my powershell script, I run an external command and look for a specific pattern in the output. For example:</p>
  
  <p>The command "eraseDevice" gives me output like this:<br></p>
  
  <pre><code>Erasing Deployment... Erasing sector 0x080a8000 
  Erasing sector 0x080c1000 
  Erasing sector 0x080e1000 
  Erasing sector 0x64010000 
  Rebooting... 
  </code></pre>
  
  <p>I want the number 0x080a8000 from this output. I have tried the following:<br></p>
  
  <pre><code>eraseDevice | select-string -simplematch -pattern 0x 
  </code></pre>
  
  <p>which returns the lines that contain the hexadecimal number. I tried doing the following as well, but all of them return errors: <br></p>
  
  <pre><code>eraseDevice | select-string -simplematch -pattern 0x -totalcount 1 
  eraseDevice | (select-string -simplematch -pattern 0x)[4] 
  eraseDevice | (select-string -simplematch -pattern 0x).split()[4] 
  </code></pre>
  
  <p><b> Desired output:</b> 0x080a8000 from the first line.
  Thanks for your help.</p>