title: How can I access pre-defined Release Management variables in a Powershell script?
body: <p>According to the <a href="https://www.visualstudio.com/en-us/docs/release/author-release-definition/understanding-tasks#pre-defined-variables" rel="nofollow">documentation</a>, there are a bunch of predefined variables available for the tasks which run in an environment for Release Management. How do I access these variables from within a Powershell script?</p>
  
  <p>For example: the <code>System.TeamProject</code> variable is defined, and should return the current TFS TeamProject. However, when I write:</p>
  
  <pre><code>Write-Host "environment var: $env:System.TeamProjectId"
  </code></pre>
  
  <p>The output in the log file is:</p>
  
  <pre><code>2016-06-07T09:26:49.5537161Z environment var: release.TeamProject
  </code></pre>
  
  <p>However, in the <code>Initialize</code> log file, the following is displayed:</p>
  
  <pre><code>4 2016-06-07T09:26:40.4121001Z Environment variables available are below.  Note that these environment variables can be referred to in the task (in the ReleaseDefinition) by replacing "_" with "." e.g. AGENT_NAME environment variable can be referenced using Agent.Name in the ReleaseDefinition: 
   ...
  34 2016-06-07T09:26:40.4277002Z [SYSTEM_COLLECTIONID] --&gt; [2043d9ba-7ec9-43f0-8e6c-96a8b28f55d8]
  35 2016-06-07T09:26:40.4277002Z [SYSTEM_TEAMPROJECTID] --&gt; [9718773d-2aee-4625-91c6-80de16301479]
  36 2016-06-07T09:26:40.4277002Z [SYSTEM_TEAMPROJECT] --&gt; [MyProject]
  37 2016-06-07T09:26:40.4277002Z [SYSTEM_CULTURE] --&gt; [en-US]
  </code></pre>
  
  <p>So this means the variable is there. I tried <code>$(System.TeamProject)</code> as suggested somewhere else, but that fails with <code>The term ... is not recognized</code>-error.    </p>
  
  <p>Also, the variables which I have configured myself in the Release Definition, e.g. <code>priority</code>, I <em>am</em> able to access with <code>$env:priority</code>.</p>
  
  <p>As a workaround I can create my own parameters in the script, and pass them in the Arguments field in the task definition, but this kind of defeats the purpose.</p>