We want to manage the variables of VariableSets from powershell as each VariableSet will probably contain several hundred variables (for only one environment, we could have up to 30 of them so imagine the number of variables to manage…).
You provide examples of adding and updating variables but I want to be able to delete all variables of a VariableSet to make sure I can import them again from our verified source. I didn’t find a way to delete variables, only VariableSet (which I want to avoid)…
Could you help me on this ?
Thanks it works. I didn’t use OctoPosh directly because I had already written some scripts and I didn’t want to start over again but it’s a great source of inspiration !
I only used
One thing though, I had to change one piece of code to work: $variableSet.Variables.clear() instead of $variableSet.Resource.Variables.clear(). I’m using Octopus 3.12.0 and Octopus.Client 4.15.3 for info.
Glad to hear its working :).
That makes sense. If you use the client through Octoposh, you’ll need to use
$variableSet.Resource.Variables.clear(), but if you use it raw from Powershell,
$variableSet.Variables.clear() would be enough.
If you are going to keep using powershell scripts to talk to the Octopus API, I definitely encourage you to try Octoposh. Next time, before you start writing a new script, ask in the Project’s Gitter channel if there isn’t something in Octoposh for what you are trying to do already and I’ll let you know