Initially we tried $step.Actions[0].ExcludedEnvironments = “Environments-3” but it said that ExcludedEnvironments is readonly property.
Let us know how to update the deployment step using Octopus.Client.dll
Thanks for getting back here! It looks like your script may need some further adjustment for it to work in this scenario. I did some testing to confirm and Octopus.Client does not seem to like sending back the $step Object on its own and expects the entire DeploymetProcess object sent back with the modified step. So I made some adjustments to the script for this to work.
I have just tested on my end and seems to work just fine.
Instead of using the $step object, I use the $deployProcess object and a foreach to find the matching step I want to edit. Then make my changes to $deploymentProcess.Step and put the entire deployment process back at the end.
You may be able to make some edits to better fit your needs, but this should work as a basic example.
It’s also worth noting that we have an open source repo with example scripts you can use for referenced when working with the Octopus.Client.
If you have any further questions here, please let me know.