title: Powershell Dynamically call Azure Devops variables inside script
body: <p>I have a requirement to load the variables inside a variable group into an azure keyvault. We do not want to link the variable group to the keyvault in order to be able to close the keyvault external network access.</p>
  <p>So I started developing a powershell script that lists the variable group variables using az cli devops extension and stores it into a powershell var.</p>
  <p>Then I iterate for each var and try to build the var name in Azure Devops format $(var) so I can use it with Set-AzKeyVaultSecret.</p>
  <p><strong>The problem:</strong> It seems the variable name has to be hardcoded for the Azure Devops pipeline to be able to convert it to it's real value.</p>
  <p>Example:</p>
  <pre><code>$pipelineVarEnc = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(&quot;$('variablename')&quot;))
  </code></pre>
  <p>Does not work:</p>
  <pre><code>        $Name = $var.Name
          $command = '$pipelineVarEnc = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(&quot;$(' + $Name + ')&quot;))'
          Invoke-command $command
  </code></pre>
  <p>Anyone knows how to bypass this issue?</p>