Using powershell scripts with teamcity

Anybody got powershell scripts working with teamcity?

If I specify my command executable as run.ps1 with any/no code contained inside, my build will never finish because the powershell process doesn't end. So I have to manually stop the build process. Fair enough, that makes sense to me, so I tried to invoke powershell through some special syntax.

If I specify my command executable as run.cmd for teamcity to call initially. Then in that file, I invoke the powershell script

powershell.exe -command "& {  }"

After running that code, powershell should automatically exit I believe. But apparently it's not.

2 Questions

Anybody know exactly what's going on?
What are the workarounds? Or shall I declare powershellscripts dont work with teamcity for whatever reason.

Heres the link to the above code in case anyone wondering where I got it from:

Comment actions Permalink


We have several reports on the issue, see details in our issue tracker at

It seemsto be some powershell issue with input streams reading/waiting. There are some workarounds in the issue and linked threads.
There is still no known solution that we can implement in TeamCity's scope to address the issue.


Comment actions Permalink

Awesome. The workaround works!


Please sign in to leave a comment.