0

I have a Powershell script that is executed in my YAML pipeline during the release stage.

I can reference group variables using $(myVar). However now I have a need to reference a variable dynamically given its name.

For instance, if I have the string 'myVar', I want to search the variable group for a variable named 'myVar' and get its value.

Is this possible to achieve ?

Sam
  • 13,934
  • 26
  • 108
  • 194

1 Answers1

1

In the end I did it like this. First I installed the Devops module for powershell so I can get group variables through devops api :

 Add-AzureDevOpsAccount    -OrganisationName "myor"   -ProjectName "myproj"   -Token "mytoken"

Write-Host -ForegroundColor DarkGreen "Getting variables group based on name"
$group = Get-AzureDevOpsVariableGroup -SearchString "dev"

Then to get a variable based on its name :

$tokenValue = $group.variables | Select-Object -ExpandProperty $someName | Select-Object -ExpandProperty Value
Sam
  • 13,934
  • 26
  • 108
  • 194