Azure App Service PreDeploy.ps1 Powershell Version

I have a PreDeploy.ps1 script in a package deployed in a Azure App Service step.
The PreDeploy script is executing correctly, however it’s running in PowerShell 5, and I’d prefer to run in PowerShell 7 (it’s installed on the Octopus server)

How can I configure the step to use PowerShell 7?

Hi @seanl,

Thanks for getting in touch!

You might be able to specify the desired Powershell version through the use of the system variable Octopus.Action.PowerShell.CustomPowerShellVersion.

If that doesn’t work then you may need to split the pre-deploy script into a separate Run an Azure Script step where you can use the Configure Features option to specify Powershell Core.
e.g.


Regards,
Paul

What value is Octopus expecting in Octopus.Action.PowerShell.CustomPowerShellVersion?
I’ve gotten this error message for 7 and 7.2, but I suspect it’s trying to run Powershell, not PowerShell Core:

Octopus Server has 7.2 core installed:

image

The value must match one of the directories contained within %PROGRAMFILES%\PowerShell.

You may be right that it won’t switch between core and standard though.

This Pre-Deploy script needs to run during the Azure App Service step, as I’m modifying config files in a way outside of what I can do with variables.

I “resolved” the issue by moving the PowerShell 7 specific bits into it’s own script, and then calling pwsh from PreDeploy.ps1.

2 Likes

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.