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!
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:
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:
Sorry I don’t have better news, but please let me know if this is helpful.
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.