cbreuser
Enthusiast
Enthusiast

vRA 8.4 powershell workflow not receiving variable from vRA

 

I have written a very simple powershell script shown below just to just how the products work. The workflow prompts the user to enter an IP address which gets passed to a powershell element in the workflow to ping the IP and email the name of the associated hostname. This works well when i run the workflow from within vRO.

When i add the workflow directly to a catalog item via the service broker and  Content, i can see the form prompting for the same information, however when i run it, it fails and the error in vRO suggests that it is because the entire IP is not being taken as the vaiable installed it takes the very first number..

 
function Handler($context$inputs) {
    
    Write-Host "Inputs were $inputsString"
    write-host $inputs.vms

    $smtp = "smtp.server" 
    $to = "emailaddress" 
    $from = "emailaddress"
    $sub = "testping"
    $vm = $inputs.vms

    write-host "testing new vaiable $vm"
    $hostname = [System.Net.Dns]::GetHostByAddress($vm).hostname


    Send-MailMessage -To $to -From $from -Subject "testing" -Body $hostname  -SmtpServer $smtp

    $output=@{status = 'done'}
    
    return $output
}
  
 
 
2022-04-21 08:40:16.747 +01:00INFO__item_stack:/item1
2022-04-21 08:40:19.930 +01:00INFOInputs were
2022-04-21 08:40:19.933 +01:00INFO
2022-04-21 08:40:19.934 +01:00INFOtesting new vaiable
2022-04-21 08:40:20.001 +01:00ERRORException calling "GetHostByAddress" with "1" argument(s): "An invalid IP address was specified."
2022-04-21 08:40:20.212 +01:00ERRORException calling "GetHostByAddress" with "1" argument(s): "An invalid IP address was specified."
2022-04-21 08:40:20.213 +01:00ERRORAt /run/vco-polyglot/function/handler.ps1:13 char:5
2022-04-21 08:40:20.214 +01:00ERROR+ $hostname = [System.Net.Dns]::GetHostByAddress($vm).hostname
2022-04-21 08:40:20.215 +01:00ERROR+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-04-21 08:40:20.216 +01:00ERROR+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
2022-04-21 08:40:20.217 +01:00ERROR+ FullyQualifiedErrorId : FormatException
2022-04-21 08:40:20.218 +01:00ERROR
2022-04-21 08:40:21.140 +01:00ERRORError in (Workflow:Powershell-PingHostname / Scriptable task (item1)#12759) Wrapped ch.dunes.scripting.server.polyglot.PolyglotRunnerException: Exception calling "GetHostByAddress" with "1" argument(s): "An invalid IP address was specified."
2022-04-21 08:40:21.152 +01:00ERRORWorkflow execution stack: ***
Labels (2)
0 Kudos
0 Replies