how to call a runbook(powershell) inside a runbook(powershell) using azure automationaccount and powershell script

Azure-learning 56 Reputation points
2022-10-28T18:45:58.353+00:00

how to call a runbook(powershell) inside a runbook(powershell) using azure automationaccount and powershell script

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,368 questions
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Alistair Ross 7,466 Reputation points Microsoft Employee
    2022-10-29T08:33:36.66+00:00

    Hello @NGaur-3476

    Within the Runbook editor, you can simply select the runbook and add it to the canvas to it runs as an inline script. (Note: this method isn't supported in PowerShell 7.1)

    255312-question1067324-automationrunbook.png

    Alternatively, you can use the cmdlet Start-AzAutomationRunbook to run your runbooks from the same or different automation accounts.

    Which ever method works for you, make sure you check out the examples and full details here. https://learn.microsoft.com/en-us/azure/automation/automation-child-runbooks

    I hope this helps provide you with the information you need. If it does, please make sure to mark the question as answered so it helps other people in future.

    Kind Regards

    Alistair

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Azure-learning 56 Reputation points
    2022-10-29T15:03:13.753+00:00

    @Alistair Ross Thank you for the response. I have a requirement where i have a function written in powershell script , this function is being utilized in multiple runbooks(for same automation account). I am trying to create a separate runbook for this powershell function .and i want to call this runbook in those multiple runbooks whenever i want to use the function.

    Is there any recommended way.
    generally if you want to call a function we can call like below.
    . .\Test-FunctionDefinition.ps1

    but i want to understand how to call this powershell function( added as azure automation runbook) in existing runbooks within azure automation account.


Your answer

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