Run Azure Automation Runbook (PowerShell) that process files on Network path.

Gayan N. Wimalarathna 0 Reputation points
2024-06-25T20:38:32.51+00:00
I am trying to run a PowerShell script on a Hybrid Worker (Windows Virtual Machine on Azure) which is failing to access shared remote location. When I run the same script on the Virtual Machine configured as the Hybrid Worker, it works as expected. I need your help to resolve this problem.
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,172 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. William 620 Reputation points
    2024-06-26T03:04:49.09+00:00

    This answer was generated in part by AI using Microsoft Copilot, in compliance with the AI Usage policy for Microsoft Q&A.

    Hi @Gayan N. Wimalarathna It sounds like there might be an issue with the permissions or the context in which the PowerShell script is running on the Hybrid Worker. When running PowerShell scripts on a Hybrid Runbook Worker (HRW) in Azure, there are several important considerations to keep in mind.

    Network Access and Firewall Rules

    Ensure that the HRW has network access to the shared remote location. If the script works directly on the VM but fails on the HRW, it might be related to network connectivity.

    Check if any firewall rules or Network Security Group (NSG) settings are blocking access from the HRW to the shared location.

    Azure Services Protected by Firewall

    • If you’re accessing Azure services (such as Azure Storage, Azure Key Vault, or Azure SQL) from your script, consider Azure Firewall settings.
    • Enabling the Azure Firewall on these services can block access from Azure Automation runbooks, even when the firewall exception to allow trusted Microsoft services is enabled, as Automation is not part of the trusted services list.
    • To access these services, use a Hybrid Runbook Worker and a virtual network service endpoint.

    Service Accounts

    • Windows Hybrid Worker jobs for HRWs run under the local System account.
    • If you’re using PowerShell 7.1 runbooks, ensure that PowerShell is installed on the HRW and added to the PATH environment variable. Restart the HRW after installation.

    If you encounter errors, consider checking the HRW logs and event viewer for additional details.

    For extension-based HRWs, there’s a workaround involving editing a configuration file. You can find the steps in the troubleshooting documentation.

    If this answer solves your issue, please vote for it so other community members know that this is a quality answer.