How to run scripts on a system Hybrid Worker in Azure Automation

Hybrid Workers in Azure Automation

When Update Management in Azure Automation was released, you could (and still) add a system Hybrid Worker to Azure Automation via the Log Analytics agent. Only you could no longer use it as a User Hybrid Worker in the User Hybrid Worker Groups and you therefore no longer see it when you want to run a script on a Hybrid Worker.

How to run scripts on a system Hybrid Worker in Azure Automation
How to run scripts on a system Hybrid Worker in Azure Automation

I started with a new customer where we convert old scripts from Resolve to Azure Automation. I can set up the Azure Automation environment myself, the Hybrid Worker was already added by the Operations team. This was only added via the Management Agent.

How to run scripts on a system Hybrid Worker in Azure Automation
How to run scripts on a system Hybrid Worker in Azure Automation

So, what now?

How to run scripts on a system Hybrid Worker in Azure Automation
How to run scripts on a system Hybrid Worker in Azure Automation

Fortunately, we are already a few years further with the development of Azure Automation, so I dived into the Docs.microsoft.com of Azure Automation and then I noticed the following:

How to run scripts on a system Hybrid Worker in Azure Automation
How to run scripts on a system Hybrid Worker in Azure Automation

This means that you can add the System Hybrid Worker to a User Hybrid Worker Group. Top! If a user Hybrid Worker Group does not yet exist, it will be created automatically.


Let’s add a System Hybrid Worker to a User Hybrid Worker Group

Log on to the Hybrid Worker.

Open Powershell and set the below location in PowerShell:
Please check the version number. This may differ from the example.

Set-Location -Path 'C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.1125.0\HybridRegistration\'

Import the module in this folder:

Import-Module .\HybridRegistration.psd1

Before we continue with the below step, go to the Azure Portal and open the appropriate Azure Automation environment and go to the Keys tab.

How to run scripts on a system Hybrid Worker in Azure Automation

Copy the Primary Access Key and URL into this piece of code & name the GroupName as you want.

Add-HybridRunbookWorker -GroupName 'Test' -Key XXXXXXX -Url XXXXXXX

The code you used should look like this:

Set-Location -Path 'C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.1125.0\HybridRegistration\'
Import-Module .\HybridRegistration.psd1

Add-HybridRunbookWorker -GroupName 'Test' -Key XXXXXXX -Url XXXXXXX

And your PowerShell console Output this:

How to run scripts on a system Hybrid Worker in Azure Automation
How to run scripts on a system Hybrid Worker in Azure Automation

You will now see a User Hybrid Worker Group in Azure Automation:

How to run scripts on a system Hybrid Worker in Azure Automation
How to run scripts on a system Hybrid Worker in Azure Automation

And you can now start a Runbook on the Hybrid Worker Group:

How to run scripts on a system Hybrid Worker in Azure Automation
How to run scripts on a system Hybrid Worker in Azure Automation

Published by

Bas Wijdenes

My name is Bas Wijdenes and I work as a PowerShell Automation Engineer. My main focus is PowerShell, Azure AD, Azure Infrastructure, Server Management, and Exchange (Online).

Leave a Reply

Your email address will not be published. Required fields are marked *