Powershell script hangs

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Symptoms

Powershell scripts doesn't return control to Bamboo, build hangs forever.

Cause

Bamboo expect child process to close its output stream (stdout and stderr) when exiting. Powershell doesn't do it.

Resolution

  1. If you're creating an executable for Powershell and running it via a Command task, add a '-inputformat none' to the command argument. The command argument field should look like this:

    -inputformat none -command
  2. If directly calling Powershell script from Bamboo, use Script task with 'Run as Powersell script option on'. Bamboo script task can handle this situation.

  3. If Powershell is called indirectly (e.g. from ant, nant, maven, other script), make sure that the streams are closed on exit:

    powershell .\test.ps1 < NUL
Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.