I must be doing something differently than what was asked and answered here because the solution does not appear to be working for me: TeamCity, passing an id generated in o
What I found is that with long values, as soon as TeamCity is breaking down the log output into two separate lines echo will not work anymore - you have to use Write-Host instead.
Write-Host "##teamcity[setParameter name='env.TEST' value='test']"
This should always work, just a side note - this value will be available only on subsequent build steps.