title: How to write "System.Collections.Hashtable" variable in Azure DevOps PowerShell
body: <p>I'm having a variable of type <code>System.Collections.Hashtable</code> I want to write this value in azure DevOps variable in Powershell script and need to use the variable in the below tasks.</p>
  
  <p>Variable created in azure DevOps: <code>header</code></p>
  
  <p><strong>Task 1</strong></p>
  
  <pre><code>Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId $env:tenant_id
  $head = $null
  $head = @{}
  $head = Get-PowerBIAccessToken
  Write-Host ("##vso[task.setvariable variable=headers]$head")
  </code></pre>
  
  <p><strong>Task 2</strong></p>
  
  <pre><code>Write-Host "Header is " $env:headers
  
  Invoke-RestMethod -Headers $env:headers -Uri 'https://api.powerbi.com/v1.0/myorg/groups'
  </code></pre>
  
  <p>But the issue in Task 2 is</p>
  
  <blockquote>
    <p>Header is  System.Collections.Hashtable <br>
    Invoke-RestMethod : Cannot
    bind parameter 'Headers'. Cannot convert the
    "System.Collections.Hashtable" value of type "System.String" to type
    "System.Collections.IDictionary".</p>
  </blockquote>
  
  <p>Since the value of the header is simply assigning the string of <code>System.Collections.Hashtable</code> and not the actual value</p>