Can I iterate over variables in a variable set (and only those in the set) in PowerShell?

I am building a PowerShell step template for the population of configuration values from Octopus to Azure Key Vault. What I would like to do is build the step with a parameter that contains the name of the variable set, and the step iterates over the variables in that variable set, storing the values in Key Vault.

I am aware of the OctopusParameters dictionary, but this contains all resolved variables. What is the best way to get the values for a variable set in a step template?


Hi Erick,

Thanks for getting in touch, your patience is greatly appreciated.

Based on the information provided in your query, this is something that’s not currently possible.

There is currently no such way to move variables from Octopus to Azure Key Vault as you won’t get all variables.

There are two factors that contribute to this;

  1. The User who produces the API-Key needs to have sufficient permissions to access all the variables.

  2. For sensitive variables, once the variable is saved, Octopus will never allow you to retrieve the value via the REST API or via the Octopus web portal. Additionally, whenever possible, Octopus will mask these sensitive values in logs.

I’ve included a link to our documentation area below which provides some additional information, please find below; (The link contains a re-direct to the appropriate area of the documentation)

If I’ve misunderstood your query in any way, or you require further assistance please let me know :slight_smile:

I’m sorry if this wasn’t the answer you were hoping for.

Kind Regards,


Thanks Reece. So with the REST API ruled out, I’m left with $OctopusParameters. I’m going to try the approach of getting the names of the variables from the REST API from within the step, then looking in $OctopusParameters to retrieve the value.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.