I\'ve got a PowerShell script as follows
##teamcity[progressMessage \'Beginning build\']
# If the build computer is not running the appropriate version of .N
I was having this exact issue while running with the -file, but for some reason the trap syntax or the 'exit' syntax provided by Kevin wasn't working in my scenario.
I am not sure why, but just in case somebody else hits the same problem, I used the below syntax and it worked for me:
try{
#DO SOMETHING HERE
}
catch
{
Write-Error $_
##teamcity[buildStatus status='FAILURE']
[System.Environment]::Exit(1)
}