Running the following script on the probe device itself returns the correct value as it should, but running it via the senor it returns the value 0. Seems to be an issue with the Foreach loop? How can I get the right output returned to the map?
$checkservice=((Get-EC2Instance -Region us-east-1) | Select -ExpandProperty RunningInstance | where {$_.Tag.Key -eq "K12-Function" -and $_.Tag.Value -eq "jsched-asg"} | select -ExpandProperty PrivateIpAddress) $cnt=@(Foreach ($InstanceID in $checkservice) { invoke-command {get-service bbk12* -computername $args[0] | where {$_.Status -eq 'Running'}} -ArgumentList $InstanceID }).count write-host $cnt":ok"
Steven Belanger
Add comment