How to dynamically fill in variables in deploy script?

Hello

I want to fill in octopus variables in my deploy script.
I created variables dest_1 till dest_10, see attached file.
In de deploy script I’m using this
For($i=1;$i -le 10;$i++){
$dest = “#{dest_$i}”
write-host $dest
}
I also tried
$dest1= “dest_$i”
$dest=#{$dest1}

All resulting at runtime
#{dest_1}
#{dest_2}

While expecting the content of vat dest_1, dest_2

Can you help me on this one?
Our version is 3.7.4

Thanks
Bart

octovar.docx (66 KB)

Hi Bart,

Thanks for reaching out! This should do the trick

$BaseVarName = "Dest_"

for($i = 1 ; $i -le 10 ; $i++){

Clear-Variable -Name "Value" -erroraction SilentlyContinue

$value = (Get-Variable -Name ($BaseVarName + $i)).Value

Write-Output $value

}

Regards,
Dalmiro