How can I run background jobs using PowerShell in Calm runbooks? | Nutanix Community
Skip to main content

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.

Hi Martin,

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


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


Reply