I am encountering a very weird issue with vRO 8.10.
I am following the simple example demonstrated in this post using PS -> Python -> NodeJS (all scriptable tasks)
https://blogs.vmware.com/management/2020/04/whats-new-in-vrealize-orchestrator-8-1.html
In the PS portion, if I do the following, the object that I return is correct in my Python scriptable task:
function Handler($context, $inputs) {
Write-Host "Welcome to PowerShell," $inputs.Name
Write-Host "*** PowerShell Version:" $PSVersionTable.PSVersion
$output=@{strOutput = '[PowerShell]'}
return $output
}
In the example above my `$output` object will have a value of {strOutput: '[PowerShell]'} in my Python scriptable task.
However, if I add the following line to my PS scriptable task, my `$output` object is null in my Python/NodeJS scriptable task:
function Handler($context, $inputs) {
Write-Host "Welcome to PowerShell," $inputs.Name
#the line below is breaking things
Set-PowerCLIConfiguration -DisplayDeprecationwarnings:$false -InvalidCertificateAction Ignore -Confirm:$false
Write-Host "*** PowerShell Version:" $PSVersionTable.PSVersion
$output=@{strOutput = '[PowerShell]'}
return $output
}
I also tried putting the scriptable task in an action, same result.
Is this a bug? How can I work around this?
Thanks
Hello @odesey,
first I want to apologize, the misbehavior I pointed out is because there is a line break in the Set-PowerCLIConfiguration command. PowerShell needs an backtick in multi-line commands, I have forgotten that. If the whole command is written in one line, Write-Host works as well. So that's definitely not the problem.
I tried this:
The output type is Properties and the Set-PowerCLIConfiguration is disabled. In the Action result we see all values.
After enabling the Set-PowerCLIConfiguration I got no ActionResult.
So I changed the Return type to Any and here I get a result, an array with two entries:
Hmm, now I tried this:
var result = System.getModule("de.stschnell").testStefan001("Stefan");
System.log(result.constructor.name);
If Set-PowerCLIConfiguration is disabled the return type is Object, if it is enabled it is Array.
It seems that the return variable type changes with the Set-PowerCLIConfiguration command. Weird.
If you use Set-PowerCLIConfiguration command you can find the properties in the array.
Otherwise it is direct in the action result.
One workaround to handle this is to add a scriptable task in the workflow and to set a variable to strOutput[1].
On this way you can then pass it to the Node.js action, as you can see here.
Best regards
Stefan
Hello @odesey,
it seems that the CmdLet Set-PowerCLIConfiguration set PowerShell into NonInteractive Mode and therewith inputs and outputs no longer work.
Without the Set-PowerCLIConfiguration command all works as expected, and with the command the first Write-Host works well and then the error message appears. Comment out your Write-Host after the Set-PowerCLIConfiguration and check your workflow if the error still occurs. Let us know your results.
Best regards
Stefan
Hi @StefanSchnell thanks for your response. I tried your suggestion like so:
function Handler($context, $inputs) {
#Write-Host "Welcome to PowerShell," $inputs.Name
#the line below is breaking things
Set-PowerCLIConfiguration -DisplayDeprecationwarnings:$false -InvalidCertificateAction Ignore -Confirm:$false
#Write-Host "*** PowerShell Version:" $PSVersionTable.PSVersion
$output=@{strOutput = '[PowerShell]'}
return $output
}
I still get a `null` value for the `strOutput` variable in my Python and NodeJS scriptable tasks.
Hello @odesey,
first I want to apologize, the misbehavior I pointed out is because there is a line break in the Set-PowerCLIConfiguration command. PowerShell needs an backtick in multi-line commands, I have forgotten that. If the whole command is written in one line, Write-Host works as well. So that's definitely not the problem.
I tried this:
The output type is Properties and the Set-PowerCLIConfiguration is disabled. In the Action result we see all values.
After enabling the Set-PowerCLIConfiguration I got no ActionResult.
So I changed the Return type to Any and here I get a result, an array with two entries:
Hmm, now I tried this:
var result = System.getModule("de.stschnell").testStefan001("Stefan");
System.log(result.constructor.name);
If Set-PowerCLIConfiguration is disabled the return type is Object, if it is enabled it is Array.
It seems that the return variable type changes with the Set-PowerCLIConfiguration command. Weird.
If you use Set-PowerCLIConfiguration command you can find the properties in the array.
Otherwise it is direct in the action result.
One workaround to handle this is to add a scriptable task in the workflow and to set a variable to strOutput[1].
On this way you can then pass it to the Node.js action, as you can see here.
Best regards
Stefan
Thanks @StefanSchnell ! Your suggestion pointed me in the right direction. To anyone else having this issue, the solution is to create:
Action Element (Language 1) ---> Action Element (Language 2)
Make sure that your output is of Type Any for your PowerShell language
Using a scriptable Task will not work!
Thanks again @StefanSchnell
Thanks for sharing your solution @odesey 👍