title: Powershell: Find specifc string/line from text file and -Replace unnecessary part from it / remove everything before
body: <p>I'd like to make Powershell script which get specific string from the line. This string might be on different lines. So text file looks like this -
  1st file -</p>
  
  <pre><code>[Bootstrap]
  buildid=400m3(Build:9702)
  ProductBuildid=9702
  ProductCode={55E61709-D7D4-43C0-B45D-BFAF5C09A02D}
  UpgradeCode={7C35B9AB-2CE3-4C18-BE7C-5B97EA089EB3}
  </code></pre>
  
  <p>2nd file -</p>
  
  <pre><code>[Bootstrap]
  ProductCode={2BB8FBB4-CFF9-434E-AA0A-40F5379C1602}
  </code></pre>
  
  <p>I need to get MSI code after ProductCode=</p>
  
  <pre><code>$openofficeSetup = "C:\Program Files (x86)\openoffice*\program\setup.ini"
  if (Test-Path $openofficeSetup)
  {
  $openofficeMSI = Select-String "ProductCode=*" $openofficeSetup
  $openofficeMSI = $openofficeMSI -Replace "*ProductCode=", ""
  msiexec.exe /x $openofficeMSI /qn
  </code></pre>
  
  <p>Line 5 with -Replace is wrong. i have no idea how to remove everything before.</p>
  
  <pre><code>PS N:\&gt; echo $openofficeMSI
  C:\Program Files (x86)\OpenOffice 4\program\setup.ini:4:ProductCode={55E61709-D7D4-43C0-B45D-BFAF5C09A02D}
  </code></pre>
  
  <p>How can I get rid of everything but MSI code?</p>
  
  <p>Offtopic: Other way would searching for MSI code in registry 
  HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\
  but using setup.ini looks easier.</p>