Changing the Azure Automation runtime configuration for hybrid worker jobs doesn't change the execution runtime

RB 0 Reputation points
2026-07-22T15:48:13.8533333+00:00

We've upgraded to the new runtime experience in Azure Automation, and I'm attempting to change the runtime environment for some of our PowerShell 5 jobs to 7.4 without any success.

The runtime definition specifies PowerShell 7.4:User's image

The script indicates that it executed with the 7.4 runtime:

User's image

But the output of $PSVersionTable from the script indicates it's still executing with PowerShell 5.1.

User's image

These scripts are running on extension-based hybrid workers which have been configured with the appropriate environment variables for PowerShell 7.4 execution.

User's image

Scripts that originate in the 7+ runtime execute in 7.4 fine. This only seems to be an issue with scripts initiated in the 5.1 runtime and updated to run in a 7+ runtime. We can delete and recreate these scripts to execute in 7+, but I'm curious why the UI shows a runtime of 7.4 when execution is still happening in 5.1.

Azure Automation
Azure Automation

An Azure service that is used to automate, configure, and install updates across hybrid environments.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. RB 0 Reputation points
    2026-07-27T21:46:07.4133333+00:00

    I did some more testing, and it appears to have to do with the method I'm using to call the runbook. We have a handful of runbooks that are initiated by a 5.1 wrapper Runnbook because of this bug. Essentially, PS7 can't parse the incoming data and fails during pre-processing before it even has a chance to log anything meaningful to the console. Since PS5 is better at parsing the incoming data, we have a PS5 runbook accept the webhook, parse the data, and pass it into Start-AzAutomationRunbook with the parsed data in the parameter set.

    I created a test runbook that just outputs $PSversionTable to the console and initialized it in the default 5.1 runtime. As expected, the output was 5.1 as expected. I changed it to 7.2, and then 7.4, and in both cases, it successfully executed with the 7.X version of PowerShell on my hybrid workers.

    User's image

    This seemed to contradict what I claimed in my original post. To make a more accurate test, I tried initiating the runbook using Start-AzAutomationRunbook in a wrapper script similar to what we're using in production.

    User's image

    This time, it ran as 5.1 despite the runtime environment being set to 7.4.User's image

    This only seems to be an issue if the runbook is initiated as PowerShell 5.1. A separate script initiated with the 7.2 runtime and run by the same wrapper script returns the expected 7.x result.

    User's image

    For now, I've just been deleting scripts that were initiated in 5.1 and recreating them in 7.2 to make this work when called by the wrapper.

    Separately, I've noticed that if I initiate a runbook in a custom 7.4 or 7.6 environment, runbooks get stuck in the queue and eventually go into a suspended mode. I've ensured that my environment variables are set properly on the hybrid workers. If I intiate them using the defauly 7.2 runtime, they end up running with 7.6 anyway since that's the installed version of pwsh. I can also change the runtime to 7.4 or 7.6 after initializing them in 7.2 without any issues.

    Was this answer helpful?

    0 comments No comments

  3. Ravi Varma Mudduluru 12,535 Reputation points Microsoft External Staff Moderator
    2026-07-27T06:31:04.4633333+00:00

    Hello @RB

    Thank you for reaching out to Microsoft Q&A.

    When you change an existing PowerShell 5.1 runbook over to a PowerShell 7.4 Runtime Environment on extension-based Hybrid Workers.

    The portal correctly shows the runbook linked to your Powershell-74 environment (and the job also reports that environment), but the process that actually starts on the Hybrid Worker is still Windows PowerShell 5.1. Runbooks that were originally created under 5.1 can keep residual behavior even after the Runtime Environment is updated. Newly created 7.x runbooks work because they are created with the correct metadata from the start.

    1. Verify the environment variable on every Hybrid Worker The variable name must be exactly: text
         powershell_7_4_path
      
      and the value must point to the folder that contains pwsh.exe (normally C:\Program Files\PowerShell\7). After setting or correcting it, restart the Hybrid Worker service or reboot the machine. Official requirement: Run Azure Automation Runbooks on a Hybrid Runbook Worker
    2. Force a clean re-publish
      • Open the runbook → Edit in portal
        • Make a trivial change (add a blank line)
          • Re-select your Powershell-74 Runtime Environment from the drop-down
            1. If it still runs as 5.1 – recreate the runbook under the 7.4 environment Export the content, create a brand-new runbook while already selecting the PowerShell 7.4 Runtime Environment, paste the code, publish, and re-attach any schedules. This is the most reliable fix for runbooks that started life as 5.1. Overview: Runtime Environment in Azure Automation

    Also confirm the Hybrid Worker extension is version 1.3.63 or higher (required for PowerShell 7.4 support).

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Was this answer helpful?

    0 comments No comments

  4. Christos Panagiotidis 3,301 Reputation points
    2026-07-22T16:08:12.8966667+00:00

    Because other 7.4 runbooks execute correctly on the same Hybrid Worker, the worker installation and powershell_7_4_path configuration are probably not the cause. Microsoft’s documented upgrade flow is to select the 7.4 Runtime environment in Edit mode, test the runbook, and then publish it. A scheduled, webhook, or production job uses the published runbook, so confirm the 7.4 environment is selected, click Publish, start a fresh job, and check $PSVersionTable.

    Also check whether source control is synchronizing the runbook. Azure Automation documentation states that source-control integration does not support PowerShell 7.4; synchronized runbooks are created as 5.1.

    Deleting the runbook or recreating schedules should not be necessary. If the published runbook shows 7.4, source control is not involved, and a new Hybrid Worker job still launches 5.1, open an Azure Automation support request with the job ID, runbook name, worker extension version, and runtime-environment metadata. That behavior would require service-side investigation.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.