title: Is there any way i can read TeamCity user defined parameter values using PowerShell script
body: <p>Is there any way i can read TeamCity user defined parameter values using PowerShell script. </p>
  
  <p>Following is what I'm trying to do.</p>
  
  <p>I have already created following parameters in the TeamCity build configuration</p>
  
  <pre><code>Variable Name           Variable Value
  =============           ==============
  variable1               ABC
  variable2               XYZ
  </code></pre>
  
  <p>Following is my powershell script that I'm using in my PowerShell Buid Step:</p>
  
  <pre><code>    #Samplay array
      $Array = @("variable1","variable2","variable3","variable4","variable5")
  
      Foreach ($item in $Array)
      {
          $VariableValue = "%" + "$item" + "%"
          if ($VariableValue)
          {
              Write-Host "Found TeamCity Variable called '$item'. Corresponding variable value is '$VariableValue'"
          }
          else
          {
              Write-Host "There isn't any TeamCity variable called '$item3'. Aborting..."
              Exit -1
          }
      }
  </code></pre>
  
  <p>The expected output is:</p>
  
  <pre><code>Found TeamCity Variable called 'variable1'. Corresponding variable value is 'ABC'
  Found TeamCity Variable called 'variable2'. Corresponding variable value is 'XYZ'
  There isn't any TeamCity variable called 'variable3'. Aborting...
  </code></pre>
  
  <p>I thought I can access the TeamCity variables using %teamcityvariablename% format. But it seems this is not working. I dont want to hardcode each and every variables in script arguments. Because the variables will change always.
  Can someone please suggest me how can i use the TeamCity user defined parameters (Configuration Parameters) in PowerShell build step. Thanks in advance.</p>