How to upgrade powershell from 5.1 to 7.1 for runbook

569 views Asked by At

I have a runbook, which I have been using for several years (with modifications). When created, it was defined to use Powershell version 5.1. The runbook is run daily through Automation.

I am now beginning to use Powershell 7.1 elsewhere, and would therefore like also to use that version in this runbook. But I cannot find ways to upgrade from Powershell 5.1 to 7.1.

How can I accomblish this task?

I have search through all runbook related properties in Azure, and tried to find a solution through Google, but in vain.

1

There are 1 answers

0
Jahnavi On

According to this Q&A discussion, the migration from PowerShell 5.1 to the most recent releases (7.1 or 7.2) is still processing. The update for altering existing runtime versions has not yet been provided.

As a workaround, if you need to update the PowerShell runtime version go to the below path and update Az modules to 7.1. It will automatically take PowerShell 7.1 runtime modules once you updated.

Path: Automation account >> Shared resources >> Modules >> Update Az Modules

enter image description here

Alternatively, you can use PowerShell command
Set-AzAutomationModule as another workaround to achieve your requirement.

Here I've downloaded the required PowerShell module from PowerShell Gallery and uploaded the module from local to Azure storage container. And later I provided the uploaded blob URL in place of ContentLinkUri with the link version as shown.

Set-AzAutomationModule -AutomationAccountName "newauto" -Name "Az" -ContentLinkUri "https://stprojectjm.blob.core.windows.net/new/az.10.4.1.nupkg" -ContentLinkVersion "10.4.1" -ResourceGroupName "xxxx"

enter image description here