How can we add the powershell scripts that are used in main powershell script in run books

Noorjahan 1 Reputation point
2021-02-17T19:28:46.147+00:00

I am trying to automate the kusto scripts by triggering from azure runbook instead from VM. I have a masterscript.ps1 which calls other powershell scripts. Could you please help me where should be we add the code of other powershell scripts in runbook created. Ways that we can call other powershell scripts from powershell runbook.
In below example, I have the masterscript which tries to invoke the other powershell scripts. In powershell runbook type, where should I add the other scripts code.
Example :

Masterscript.ps1 -
write-host n n "Master script initiate" n n

write-host n "########################################################################################################################################################################################" n n write-host "investigatorDB_v3.ps1 script initiate" n n write-host "########################################################################################################################################################################################" n `n
&"$PSScriptroot\investigatorDB_v3.ps1" -save

write-host n "########################################################################################################################################################################################" n n write-host "investigatorDB_ClosedSync_v3.ps1 script initiate" n n write-host "########################################################################################################################################################################################" n `n
&"$PSScriptroot\investigatorDB_ClosedSync_v3.ps1" -save

write-host n "########################################################################################################################################################################################" n n write-host "investigatorDB_UpdateState_v3.ps1 script initiate" n n write-host "########################################################################################################################################################################################" n `n
&"$PSScriptroot\investigatorDB_UpdateState_v3.ps1" -save

write-host n n "Master Script Complete" n n

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,171 questions
{count} votes

1 answer

Sort by: Most helpful
  1. tbgangav-MSFT 10,416 Reputation points
    2021-02-20T12:07:42.087+00:00

    Hi @Noorjahan ,

    In Azure Automation we have a feature to create modular runbooks so a parent runbook can call one or more child runbooks to perform required functionality. On the other hand, as @Morten Lerudjordet 's mentioned, you could also go with traditional way of creating functions in a module and then can import it to Azure Automation.

    0 comments No comments