thank you for replay.
Original Message:
Sent: May 31, 2024 02:21 AM
From: xian
Subject: work with Powershell without PShost
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);
Original Message:
Sent: May 30, 2024 12:32 PM
From: jeep2004
Subject: work with Powershell without PShost
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 -Quietif ($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