Foreach value

Hi,

I’m trying to build some pipelines in Azure Devops, and need a way to loop through a hashtable or PSObject and create DevOps variables that can be passed through the pipeline.

for example:

$myVariables = @{
  'ID' = 'kf5jkdfgjld'
  'Acc' = '4489933'
}

# now need to take those values and pass to this cmdlet 

foreach ($Item in $myVariables){
      Write-Host "##vso[task.setvariable variable=$MyVariable.Key]$MyVariable.Value"
}
The idea the the hashtable could contain loads of values and i dont want create a line for everyone.

Hope that makes senes.

Thanks

$myVariables = @{
  'ID' = 'kf5jkdfgjld'
  'Acc' = '4489933'
}
foreach ($Item in $myVariables){
    foreach ($Key in $Item.Keys) {
          "##vso[task.setvariable variable=$Key]$($Item.$Key)"
    }
}
[Array]$myVariables = 'ID,kf5jkdfgjld'| ConvertFrom-CSV -Header "Name","Value" -Delimiter ","
$myVariables += 'Acc,4489933'| ConvertFrom-CSV -Header "Name","Value" -Delimiter ","

foreach ($Item in $myVariables){
Write-Host ($Item.Name +" IS "+$Item.Value)
}