1

We have a bamboo plan which will trigger a PowerShell script to run in one of the remote systems we have. This PowerShell script is invoking an ant.bat file which is trying to fetch JAVA values and failing.

The output: Screenshot of the error

The error in bamboo log is same as the error from PowerShell ISE.

Also I'm getting the same error for java -version command in PowerShell ISE.

How bamboo is executing the PS script? through ISE or terminal or any other way? If it executes in ISE is there a way to tell bamboo to run the script in terminal instead of ISE?

Why there is a difference in execution between terminal and ISE?

Any help on this will be helpful. Thanks in advance :)

Things I tried:

Made sure JAVA is installed and environment variables are set.

Logged into the same remote system and executed the same PS script manually from PS Terminal directly and it is passing. But when I run the same script from PowerShell ISE it is failing with the same error as bamboo log.

Asuwathaman R C
  • 303
  • 1
  • 6
  • 10
  • 1
    In short: The obsolescent ISE surfaces _stderr_ output from external programs via _PowerShell's error stream_ (which in proper terminals/consoles happens only in _remoting_ calls), which has two implications: (a) Stderr lines - which may or may not represent _errors_ - are _formatted_ as if they were _PowerShell errors_, with additional, confusing information. (b) if `$ErrorActionPreference = 'Stop'` happens to be effect, any stderr output causes a _fatal (script-terminating) error_. See [this answer](https://stackoverflow.com/a/75949989/45375) for more information. – mklement0 Sep 02 '23 at 15:35
  • As an aside: The PowerShell ISE is [no longer actively developed](https://docs.microsoft.com/en-us/powershell/scripting/components/ise/introducing-the-windows-powershell-ise#support) and [there are reasons not to use it](https://stackoverflow.com/a/57134096/45375) (bottom section), notably not being able to run PowerShell (Core) 7+. The actively developed, cross-platform editor that offers the best PowerShell development experience is [Visual Studio Code](https://code.visualstudio.com/) with its [PowerShell extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell). – mklement0 Sep 02 '23 at 15:36
  • I don't know what Bamboo uses to host PowerShell, but presumably it behaves like the ISE because remoting / hosting of PowerShell via its SDK is involved. – mklement0 Sep 02 '23 at 15:38

0 Answers0