title: Using Get-Variable to retrieve variables from library in Azure Pipelines
body: <p>I have a <code>HelloWorld</code> variable library in Azure DevOps containing the variable <code>$foo=bar</code>.</p>
  <p>I want to read it in my pipeline using <code>Get-Variable</code> but regardless of the scope I give to my search, the variable is nowhere to be found. It is however, accessible &quot;directly&quot; (as shown below):</p>
  <pre class="lang-yaml prettyprint-override"><code>variables:
    - group: HelloWorld
  
  stages:
    - stage: test
      jobs:
      - job:
        displayName: Retrieve variables
        steps:
          - task: Powershell@2
            displayName: Variable retrieval
            inputs:
              targetType: inline
              verbose: true
              script: |
                # This works
                Write-Host &quot;Direct access: $(foo)&quot;
                # All of the following returns nothing
                $indirectAccess = Get-Variable -Name &quot;foo&quot; -ValueOnly -ErrorAction SilentlyContinue
                $indirectAccess = Get-Variable -Name &quot;foo&quot; -ValueOnly -ErrorAction SilentlyContinue -Scope Global
                $indirectAccess = Get-Variable -Name &quot;foo&quot; -ValueOnly -ErrorAction SilentlyContinue -Scope Script
                Write-Host &quot;Indirect access: $indirectAccess&quot;
  </code></pre>
  <p>Can I in any way retrieve library variables with <code>Get-Variable</code>?</p>
  <p>The reason it's so important for me to know whether it's possible is because I need to retrieve values with variables which name is a variable itself... And so far I haven't found a way to do it except than with <code>Get-Variable</code>.</p>