New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Custom EXE/script sensor returning 0

Votes:

0

Your Vote:

Up

Down

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

custom-script-exe powershell return-code

Created on May 8, 2018 2:54:14 PM by  steven belanger (0) 1



2 Replies

Votes:

0

Your Vote:

Up

Down

Dear Steven,

I assume that the foreach loop is correct, but that the statement

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

yields an error message, or a different result when you run it with the 32 bit powershell. Please test that. If the 32 bit powershell shows the correct output, please check the sensor settings if you use the context of the probe, or the Windows credentials of the device object.

Created on May 8, 2018 9:05:36 PM by  Arne Seifert [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Arne Seifert,

Changing the sensors Security Context setting to "Use Windows credentials of parent device" allowed the sensor to return the correct value of the script. Thanks for your help!

Steven Belanger

Created on May 9, 2018 11:22:24 AM by  steven belanger (0) 1



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.