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,