0

I have several Workflow scripts defined. I want to write a master script to reference the dependent scripts. I am expecting there is some kind of Import or Include statement to reference the dependent scripts and make the workflows available.

How do I make this work ?

Example: dependent.ps1

workflow doSomething
{
   Write-Output "Hello World"
}

master.ps1:

Import dependent.ps1
workflow master
{
   doSomething
}

1 Answer 1

1

You can include the contents of another script in to your script via dot sourcing:

. .\dependent.ps1

workflow master
{
   doSomething
}

You could use a loop to do this for several scripts and even use Get-ChildItem to discover them programmatically:

$ScriptsToInclude = Get-ChildItem \path\to\your\scripts\*.ps1

ForEach ($Script in $ScriptsToInclude.Fullname) {
   . $Script
}
Sign up to request clarification or add additional context in comments.

1 Comment

that does the trick locally, how do I make this work in Azure Runbooks ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.