here_for_python
here_for_python

Reputation: 41

Including a runbook.ps1 script in your runbook

Scenario:

I have 2 runbooks, runbook A and runbook B.

Inside runbook B, I want to load runbook A into memory.

Running below doesn't work, can someone help me out please?

.\runbookb.ps1
. ./runbookb.ps1

Upvotes: 1

Views: 1369

Answers (1)

Anatoli Beliaev
Anatoli Beliaev

Reputation: 1664

Assuming that you want to invoke runbook B from runbook A, first of all please make sure runbook B exists in your Automation Account and is published. Then, depending on the runbook type, you need to use different syntax:

  • For PowerShell runbooks, the correct syntax is: ./runbookb.ps1 or . ./runbookb.ps1 (depending on whether you want the "dot-sourcing" behavior or not)
  • For PowerShell Workflow runbooks, the correct syntax is: runbookb

If you really want to load the runbook content into memory, this is different:

  • For PowerShell runbooks: Get-Content ./runbookb.ps1
  • For PowerShell Workflow runbooks: use the Export-AzureRmAutomationRunbook cmdlet.

Upvotes: 2

Related Questions