VMware Cloud Community
odesey
Enthusiast
Enthusiast
Jump to solution

vRO PS return bug

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

 

0 Kudos
1 Solution

Accepted Solutions
StefanSchnell
Enthusiast
Enthusiast
Jump to solution

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:

StefanSchnell_0-1684433142802.png

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.

StefanSchnell_1-1684433306378.png

So I changed the Return type to Any and here I get a result, an array with two entries:

StefanSchnell_2-1684433542113.png

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.

StefanSchnell_3-1684434744438.png

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].

StefanSchnell_5-1684435298944.png

On this way you can then pass it to the Node.js action, as you can see here.

StefanSchnell_4-1684435241964.png

Best regards
Stefan

 


More interesting information at blog.stschnell.de

View solution in original post

5 Replies
StefanSchnell
Enthusiast
Enthusiast
Jump to solution

Hello @odesey,

it seems that the CmdLet Set-PowerCLIConfiguration set PowerShell into NonInteractive Mode and therewith inputs and outputs no longer work.

StefanSchnell_0-1684393470278.png

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


More interesting information at blog.stschnell.de

odesey
Enthusiast
Enthusiast
Jump to solution

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.

0 Kudos
StefanSchnell
Enthusiast
Enthusiast
Jump to solution

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:

StefanSchnell_0-1684433142802.png

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.

StefanSchnell_1-1684433306378.png

So I changed the Return type to Any and here I get a result, an array with two entries:

StefanSchnell_2-1684433542113.png

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.

StefanSchnell_3-1684434744438.png

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].

StefanSchnell_5-1684435298944.png

On this way you can then pass it to the Node.js action, as you can see here.

StefanSchnell_4-1684435241964.png

Best regards
Stefan

 


More interesting information at blog.stschnell.de

odesey
Enthusiast
Enthusiast
Jump to solution

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 

StefanSchnell
Enthusiast
Enthusiast
Jump to solution

Thanks for sharing your solution @odesey 👍


More interesting information at blog.stschnell.de

0 Kudos