Start A Child Runbook From Azure Automation Hybrid Worker on the Same Hybrid Worker Group

Today I was writing a PowerShell runbook (let’s call it Runbook A) that’s designed to run on on-prem hybrid workers. At the end of Runbook A, I needed to kick off another runbook (let’s call it Runbook B) that must run on the same Hybrid Worker group. Because I don’t want to hardcode the Hybrid Worker group name in the script (or using an Automation variable), I wrote a very simple function that returns the Hybrid Worker configuration (including the Hybrid Worker group name) from registry if runs on a Hybrid Worker.

To use it, simply place the function shown below in the parent runbook (Runbook A in this case), and call this function to retrieve the Hybrid Worker configuration.

Function:

SNAGHTML2f76e97b

Code Sample:

Note:

The Get-HybridWorkerConfig function would return $null value if the computer is not a Hybrid Worker.

Leave a Reply

%d bloggers like this: