This is how to run your code as PowerShell action:
function Handler($context, $inputs) {
$vmName = $inputs.vmName
$pingResult = Test-Connection -ComputerName $vmName -Count 2 -Quiet
if ($pingResult) {
Write-Host "A reply was received from Hostname/IP $vmName!"
return $true
}
else {
Write-Host "No answer to ping from $vmName!"
return $false
}
}
However, this did not work well for me on Orchestrator 8.16 (with an additional debug command
Test-Connection -ComputerName $vmName -Count 2 | Format-Table | Out-String | Write-Host):

Orchestartor 8.13 was more verbose:

So this is probably not working as the code runs in a container.
What does work, is pure JavaScript:
return System.isHostReachable(vmName);
