Question

How can I run background jobs using PowerShell in Calm runbooks?

  • 14 October 2021
  • 2 replies
  • 124 views

Userlevel 2
Badge +2

Hi!

I have a script in a runbook that dynamically executes a background job using another script, also placed on disk, but there is no output from that background job even if I explicitly ask for the result with Receive-Job.

Here’s the code I run to execute the external script as a background job and then get the results:

$job = Start-Job -FilePath $pathToScript

Receive-Job $job

The runbook executes without problems but there is no output. If I use the following method to invoke the external script I get the expected output from the runbook:

& $pathToScript

I would like to use background jobs though as there are benefits to that I’d like to use. Can I use background jobs with Calm and if so, how?

Thanks.


2 replies

Userlevel 2
Badge +2

Thanks Jose for the quick answer. I will give this a try ASAP and report back.

Userlevel 4
Badge +5

Hi Martin,

Happy to hear you are using Calm Runbooks. Please include in your Receive-Job the parameter -Wait

Reply