title: Cannot convert value to type "System.Version"
body: <p>I cannot convert a properly formatted string stored in a variable into a version type. The issue must be with the variable as it works fine if I provide the value manually but I don't know what could be wrong with it. I am new to PowerShell so I'm not sure where to look.</p>
  
  <p>Here's my variable:</p>
  
  <pre><code>Write-Host "$env:BUILD_BUILDNUMBER"
  1.0.0.20​
  </code></pre>
  
  <p>Is it really a string? Yes:</p>
  
  <pre><code>($env:BUILD_BUILDNUMBER).GetType().fullname
  System.String
  </code></pre>
  
  <p>Let's convert it into a version:</p>
  
  <pre><code>[version]($env:BUILD_BUILDNUMBER)
  Cannot convert value "1.0.0.20​" to type "System.Version". Error: "Input string was not in a correct format."
  </code></pre>
  
  <p>Works just fine when tried manually:</p>
  
  <pre><code>[version]("1.0.0.20")
  </code></pre>
  
  <p>Any idea what's wrong with my variable? I can't change it as it's provided to me as is.</p>
  
  <p>Thanks!</p>