title: Dynamic variable name in VSTS (Azure DevOps) pipeline
body: <p>I have a pipeline variable called <code>TestVariable</code>.</p>
  
  <p>I can easily access this variable from a PS script like so:</p>
  
  <pre><code>write-host $(TestVariable)
  </code></pre>
  
  <p>But if the name of that variable was dynamic, is there any way I can access the variable value from PS?</p>
  
  <p>For example, the name of the variable would go into a string variable. I've tried these combinations as experiments...they just return the variable name, not the value (not surprisingly):</p>
  
  <pre><code>$varname="TestVariable"
  
  write-host $($varname)
  write-host $("$varname")
  write-host $"($varname)"
  write-host $("($varname)")
  </code></pre>
  
  <p>I think the answer is no, but I want to be sure. Any help much appreciated!</p>
  
  <h2>Edit - note</h2>
  
  <p>Both answers answer the question but don't solve my problem. After trying the solutions I realized I missed an additional complication which the answers don't help with unfortunately. Am noting here in case someone tries to do something similar.</p>
  
  <p>The extra complication is, the value of the variable is set during the release (I'm trying to access ARM template output variables).</p>
  
  <p>I thought I may be able to hit the API and get the 'live' variable value but unfortunately the release data does not exist (from the API) until the release completes.</p>
  
  <p>So when I call this during a release:</p>
  
  <blockquote>
    <p><a href="https://vsrm.dev.azure.com/" rel="nofollow noreferrer">https://vsrm.dev.azure.com/</a>{company}/{project}/_apis/release/releases/$($releaseId)?api-version=5.0</p>
  </blockquote>
  
  <p>I get "Release with ID 38 does not exist".</p>