Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Run PowerShell Core 6.x or 7.x script from Bamboo script task

Hello, colleagues.

Is there any way to run  PowerShell Core 6 or 7 from  a standard Bamboo script task on a  Bamboo agent that works on Windows Server 2016 LTSC (I guess same will apply to Windows Server 2019)?

I went through task documentation and I discovered that there's no mention about support for these PowerShell versions.

PowerShell 6 and 7 are more robust and have lots of improvements if we compare them with PowerShell base 5.1 (which was shipped in windows server 2016). 

However, Microsoft had changed significantly a way of installation and even PowerShell.exe named differently:

  • PowerShell.exe is now pwsh.exe;
  • Different folders are in use for modules and profiles then for the 5.1, etc.;

https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows?view=powershell-7.1

It looks like it won't work by default.

 

So, any ideas or road maps about this?

1 answer

1 accepted

1 vote
Answer accepted

Hi @Vitalii C_ 

Assuming you have done a standard installation of PowerShell Core on your build agent image, then it should work if you place your PowerShell in a script file, then using  cmd.exe task, run it like so

pwsh.exe -File yourscript.ps1
exit %ERRORLEVEL%

 

If using Linux build agents with PowerShell core, you can inline PowerShell script with the appropriate shebang in a shell script task

#!/usr/bin/env pwsh

Get-ChildItem ...

Hi, @Alistair_Mackay

Happy New Year and Merry Christmas.

Thanks for sharing.

But my question is not about proxy call from command task, but about ability to run inline/file PowerShell script with a script task.

So, again, thanks for sharing.

I have the same idea about file-based  proxy call approach if I will figure out that my scenario above is not an option.

 

Also, I will mark you reply as "accepted", because it's covering part of the solution.

AFAIK there's no way currently to run inline PowerShell Core script tasks in Bamboo on Windows agents, not until Atlassian or a 3rd party provides a task plugin for it. Only with the above mechanism on Linux agents can you run inline.

Like Vitalii C_ likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 7.2 is here!

I'm happy to announce that Bamboo 7.2 has been released and it’s overflowing with awesome new features. This will be the last major Server release before the launch of Bamboo DC. Bamboo logs We...

477 views 5 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you