VMware Aria Automation Orchestrator

 View Only
  • 1.  work with Powershell without PShost

    Posted May 30, 2024 05:38 PM

    Hi 
    Need to runs simple command with PowerShell but I want to do it without psHost

    I the action tab I open a new when I open a new Action and Edit to PowerShell

    like this 

    function Handler($context, $inputs) {
        $inputsString = $inputs | ConvertTo-Json -Compress
    
        Write-Host "Inputs were $inputsString"
    
        $output=@{status = 'done'}
    
        return $output
    }
    

    and this is the command is Ps  I want to put  in this action

    param (
        [string]$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
    }
    

    who I work with this 

    THX



  • 2.  RE: work with Powershell without PShost

    Posted May 31, 2024 12:15 PM

    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);




  • 3.  RE: work with Powershell without PShost

    Posted Jun 02, 2024 10:28 AM

    HI xian

    thank you for replay.

    about this command , its work from me fine 
    thanks again 

    return System.isHostReachable(vmName);