title: Using if condition to compare in PowerShell
body: <p>I am trying to get the .Net version from the system and trying to check does my system have .Net version greater than or equal to 4.6 or not. Below is the code. From the code I am able to retrieve the release version. I am facing a problem in the if condition.</p>
  
  <pre><code>$myArray = @()
  
  $myArray = @(Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse |
      Get-ItemProperty -Name Release,Release -EA 0 |
      Where { $_.PSChildName -match '^(?!S)\p{L}' } |
      Select Release)
  Write-Output $myArray[0]
  Write-Output $myArray[1]
  
  $var1 = 393295
  foreach ($var in $myArray) {
      Write-Output $var
      if ($var -ge $var1) {
          Write-Output same
      } else {
          Write-Output NOT same
      }
  }
  </code></pre>
  
  <p>I am getting this error:</p>
  
  <pre><code>Cannot compare "@{Release=461808}" to "393295" because the objects are not the
  same type or the object "@{Release=461808}" does not implement "IComparable".
  At C:\Users\Desktop\DotNet.ps1:13 char:9
  +     if ($var -ge $var1) {
  +         ~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
      + FullyQualifiedErrorId : PSObjectCompareTo
  </code></pre>