How to pass variables between tasks in runbooks using PowerShell?

  • 9 November 2021
  • 6 replies

Userlevel 2
Badge +2

Hi all.

I’ve been searching all over the Internet, and the Nutanix documentation, to figure out how to pass variables from one task in a runbook to the next. I know that I need to print it to the console in the format “statusMessage = ‘This is the status message’” but so far I’ve tried with Write-Host, Write-Output, and Write without any luck.

I’ve also tried using both @@{statusMessage}@@ and @@{Task1.statusMessage}@@ in the next step without any difference.

How am I supposed to do this, and why isn’t it properly documented?



Best answer by Nuthawin 9 November 2021, 14:53

View original

This topic has been closed for comments

6 replies

I believe you can set the task ‘Type’ to ‘Set Variables’ and then ‘Script Type’ to ‘Powershell’.

Defined what variable you want to pass along in the Powershell:

Write-host "pass_var=VALUE"

Then at the output section below, put in pass_var.

Also, create a variable ‘pass_var’ in the runbook under the ‘Configuration’ tab to hold this value.


Give it a try and good luck.



Userlevel 4
Badge +5

Hi Martin,

Sorry to hear you couldn’t find what you are looking for. Please follow the steps Joe suggested, you can also have a look to our documentation: Creating a Set Variable Task

If you are still facing any issue, please don’t hesitate to leave a message.



Userlevel 2
Badge +2

Hi Joe!

I now realize that I forgot to add the variable to the configuration. /facepalm

Thanks for the quick reply, I’ll give it a try. 

Userlevel 2
Badge +2

Hi Jose.

Thanks for the quick reply and the link to the documentation.

Do I really have to select the task type as Set Variable though? I can’t remember having to do that previously. Using a task of type Execute, writing the variable to the console, and including it in the configuration as Joe pointed out, would be enough IIRC.

Userlevel 4
Badge +5


You have to use set variable always when you are creating custom variables. It’s the only way where you get an Output textbox. There you write the Calm variable that will get the value that you are printing out in your script.

Built-in macros that start with calm_, or name, address…, they don’t need to be set because they are part of the system. 

Userlevel 2
Badge +2

Thanks Jose for the clarification.

I am obviously misremembering the POC we did last year. :)