title: Comparing installed and current versions
body: <p>I want to get installed versions and current versions from a log file and I have got the output by using the following commands:</p>
  
  <pre><code>$versions = Select-String -Path $path -Pattern "Comparing product versions" |
              % { $_.Line.Split() }
  
  $installed = $versions[6]
  $installed = echo "$installed".Trim(",")
  $current   = $versions[7]
  </code></pre>
  
  <p>The problem is: I don't want hardcoding. Is there any method like regex to replace this and to get installed version and current version seperately.</p>
  
  <p>This is what the relevant log line looks like:</p>
  
  <pre>ISS_LOG [14:45:36]: Comparing Product Versions - Installed[1.2.0.10], Current[1.2.0.10]</pre>
  
  <p>Trying the 1st solution, I get an error:
  <a href="https://i.stack.imgur.com/SjfEJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SjfEJ.png" alt="Error - cannot index into null array"></a></p>