title: Update Variable in TeamCity powershell script
body: <p>I am trying to update an enviroment variable in TeamCity using Powershell script. However, it does not update the value of the variable. How can I do this? </p>
  
  <p>Below is my current code which gets the currentBuildNumber fine:</p>
  
  <pre><code>$currentBuildNumber = "%env.currentBuildNumber%"
  $newBuildNumber = ""
  Write-Output $currentBuildNumber
  If ($currentBuildNumber.StartsWith("%MajorVersion%") -eq "True")
  {
   $parts = $currentBuildNumber.Split(".")
   $parts[2] = ([int]::Parse($parts[2]) + 1) + ""
   $newBuildNumber = $parts -join "."
  }
  Else
  {
   $newBuildNumber = '%MajorVersion%.1'
  }
  
  //What I have tried
  $env:currentBuildNumber = $newBuildNumber
  Write-Host "##teamcity[env.currentBuildNumber '$newBuildNumber']"
  Write-Host "##teamcity[setParameter name='currentBuildNumber' value='$newBuildNumber']"
  </code></pre>