I have a Azure Devops Pipeline $PIPELINE with a task group $TASKGROUP, and one of the actions in that task group is a powershell task $TASK ( a powershell task, not a AzureCloudPowerShellDeployment task or AzurePowershell task, which are different and have answers to this question)
I'd like to run the task under powershell 5.1 because of some features in the script I'm running require it (mainly $PSEdition, which some of the script's module dependencies expect). However, there doesn't seem to be any way to force a specific version of powershell
How can I force the $TASK to run with powershell version 5.1 or higher?
The task simply invokes powershell.exe
from the path. It assumes you have installed the appropriate version of PowerShell on the agent.
Your script could relaunch itself to switch between versions..
Or you could enable the PowerShell Core option if your scripts work with that.
There is no PowerShell task in Azure DevOps which will auto-install your desired version of PowerShell.