Azure automation: Start-AutomationRunbook – New simple way to start runbook jobs from within a runbook!

Microsoft has just released a new cmdlet in the realm of Azure automation.


The cmdlet is designed to start runbook jobs in the same account as the current running runbook, without having to define any endpoints/credentials/etc.

Syntax is:

Start-AutomationRunbook [-Name] <string> [-Parameters <IDictionary>] [-RunOn <string>] [<CommonParameters>]

How to start a runbook:

Start-AutomationRunbook – Name "Test-JSONOutput"

Start a runbook on a hybrid worker

Start-AutomationRunbook – Name "Test-JSONOutput" –RunOn "Denmark"

NB! The cmdlet can only be used inside runbooks

Great little addition to the built in cmdlets in Azure automation!

Comments (5):

  1. Jarko says:

    That CMDLet could be really useful, great info!

    How do I monitor runbook job output and status?

    Get-AzureAutomationJob and Get-AzureAutomationJobOutput as usually?

    • Neil says:

      Did you ever find out how to get the Job Status? Those 2 cmdlets dont work and there doesnt seem to be a:
      Get-AutomationJob cmdlet etc?

      • Jarko says:

        Nope, did not, hoping for some info from Jakob :-)

        • sorry for the late reply. Unfortunately there is not a GEt-AutomationJoboutput command and I think we’re supposed to use Get-AzureAutomationJobOutput, but I am having problems too at the moment

          • So I finally got it tested properly.
            I also had problems using the cmdlets, but it was because I had uploaded my own versions of some of the azure modules. Either you need to use the provided (globa) ones or upload all of them yourself. I updated this blog with the information:

            but unfortunately you have to use the stnadard commands, which means you could easily use the normalt Start-AzureRMAutomationrunbook instead

            Here is a code example:

            $cred = Get-AutomationPSCredential -Name ‘DefaultAzureCredential’
            Login-AzureRmAccount -credential $cred

            $PSDefaultParameterValues = @{
            “*AzureRMAutomation*:ResourceGroupName” = “xx-West-Europe”
            “*AzureRMAutomation*:AutomationAccountName” = “xx”

            $JobId = Start-AutomationRunbook –Name “Test-Output”

            Write-Output “Job Started:”

            $Status = $null
            do {
            if($Status -ne $null)
            “Job not complete – Status: $Status – Sleeping”
            Start-Sleep -Seconds 2

            $Status = Get-AzureRMAutomationJob -Id $JobId | Select-Object -ExpandProperty Status

            } while (($status -ne “Completed”) -and ($status -ne “Failed”) -and ($status -ne “Suspended”) -and ($status -ne “Stopped”) )

            if($status -eq “Completed”)
            Get-AzureRmAutomationJobOutput -id $JobId -Stream Output | Get-AzureRmAutomationJobOutputRecord
            Get-AzureRmAutomationJobOutput -id $JobId -Stream “Any” | Get-AzureRmAutomationJobOutputRecord

Leave a Reply