Another case of poor documentation = time wasted, this time, courtesey of Atlassian's Bamboo.

I need to make a deployment project that runs some powershell scripts - OK so far. They have a script task, which can run powershell - still OK.

But..In order to make the environments different, I wanted to inject some variables. They have a variables button in Edit Environment, which I clicked and there was 1 annoying thing and 1 good thing. The good thing was that they said on Windows, you use %NAME% in scripts and the annoying thing was that it was unclear why the Scripts examples were capitalized and the variable names were not. I could work that out but really, they should have been consistent.

Anyway, I could NOT get these to work. I would try things like  

az group create %bamboo_DEPLOYMENT_NAME%

(using capitals just in case) and no dice. All kinds of random errors and weirdness, I eventually worked out that it must not be substituting them properly, but without any useful echoing from Bamboo, I tried all kinds of combinations. Fortunately, the log message proved that the environment variables were there and were correctly named.

I eventually realised that the help in the variables page was incomplete, their online docs were poor and even some forum questions were not answered  and was really only referring to command line usage, not Powershell usage. SO instead of az group create %bamboo_DEPLOYMENT_NAME%

it should be:

az group create $Env:bamboo_DEPLOYMENT_NAME

And then it all worked!