Run step template with powershell core

I am having an issue running a step template in powershell core. I have enabled the feature for the step template that selects PowerShell core.

This is what I get when I just “run” the step template on the octopus server (where core is installed)

image

However if I integrate that step template into the process of a project it works fine.

image

Is this just a bug? I am using version 2020.6.5394.
I use the “run” feature of my custom step templates often when testing.

Hi Daniel,

Thanks for getting in touch! I’m sorry to see you’re hitting this unexpected issue. We haven’t had any luck reproducing this issue locally in version 2021.3.8275, however. Setting PowerShell core on the PS Version feature on the step template returned the PS Core version both when run as a step in a deployment and run standalone. I don’t see any release notes between these two versions to confirm it’ll be fixed after an upgrade, however the behavior here might have been fixed in conjunction with another related issue.

I’d be happy to look closer at this one in your current version - would you be willing to send through the resulting task logs from both scenarios? Hopefully comparing the two might give us some indication as to how to narrow down what’s causing this.

I look forward to hearing back and getting to the bottom of this one!

Best regards,

Kenny

Hi Kenny,
Thanks for getting in touch. I would be happy to send in the task logs for you to analyze. Is there a private place I can upload these?

Hi Daniel,

You should be able to use the following temporary secure link to upload these: Support - Octopus Deploy

Let me know once you’ve done that and we will review them.

Best,
Patrick

Hi Patrick,
I’ve uploaded the log files. Hopefully these are what you are looking for.

Thanks for your help.

Hi Daniel,

Thanks for sending those logs through, they’re exactly what we were looking for.

It looks like I’m able to reproduce this behavior, and I had a quick question I hope you don’t mind answering. Within your process and Run a Script step, do you have Powershell Core edition selected like this:

I’m guessing this is what’s causing the difference in output, but I just wanted to confirm. Unfortunately, we don’t currently have a feature within the Script Console that allows for selecting a PowerShell edition in this same manner, but you are welcome to add this as a feature request to our UserVoice to get added to future Octopus versions.

As a workaround, I was able to get the Powershell Core version to report by using the following block at the top of my test script:

param([switch]$_restart)
if (-not $_restart) {
  pwsh -File $MyInvocation.MyCommand.Definition -_restart
  exit
}

$PSVersionTable

You might use a test script with this to see if it works for your needs, as I haven’t done any thorough testing with it myself.

Otherwise, your only other option might be to use a Runbook or a Deployment Process Step with the feature turned on as a workaround for now. Note that you can also set the system variable at the project level by using Octopus.Action.PowerShell.Edition as the variable and 'Core' as the value:
image

Sorry I don’t have better news, but please let me know if this is helpful.

Best,
Patrick

Hi Patrick,
Yes indeed, I do have the powershell core option selected in my step template. Running the step template ad hoc just seems to ignore that setting which is odd since the step template is marked as requiring it.

There is nothing in the “Run a script” step that indicates powershell core as that step is based on a the template.

Thanks for the work around suggestions. I will just have to beware of that limitation for now. Maybe in a future version the ad hoc runner can be updated to check this value.