Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

Looking for guidance - Trying to get the results from a powershell script using a vRO workflow.

$
0
0

Hello Everyone,

 

I'm hoping someone here can give me some guidance how to get the results from a powershell script and then pass that data into an output variable.

 

Here is the code I'm using to execute the powershell script. It works great.

try {

  session = PowerShellHost.openSession();

  var script =  '& "' + PowerShellScript + '" ';

  PowerShellOutput = System.getModule("com.vmware.library.powershell").invokeScript(PowerShellHost,script,session.getSessionId()) ;

} finally {

  if (session){

  PowerShellHost.closeSession(session.getSessionId());

  }

}

 

Here is an snippet of my powershell script...

Foreach ($ip in $ipAddresses) {

    $pingTest = Test-Connection -ComputerName $ip -Count 1 -Quiet

    if ($pingTest) {

        if (Test-NetConnection -ComputerName $ip -Port $ESXPort -InformationLevel Quiet) {

            #Trigger ESX config

            $Results = $ip

            }

        if (Test-NetConnection -ComputerName $ip -Port $DRACPort -InformationLevel Quiet) {

            #Trigger DRAC config

            $Results = $ip

            }

    }

}

Return $Results

 

How would I be able to get the output from the powershell script and put that into a variable that I can then use in another workflow? I've seen suggestions like getHostOutput() or getResults(), but I'm failing at getting the syntax right.

 

Any suggestions would be very helpful.

 

Thanks,


Viewing all articles
Browse latest Browse all 6251

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>