What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

EXE Custom Sensor using Powershell

Votes:

0

I have stumped Support with this one.

I want to create an EXE Custom Sensor to run a WMI command against a remote server that returns back the number of patches applied in the last X number of days. I have set the Parameters to %host, see it as $args[0] in my powershell script but cannot use it in -computername field for it to return any value. This works fine from command line and passing in the argument. From PRTG, it only returns the value of $srv.

$srv = $($args[0])
$ans = gwmi win32_quickfixengineering -cn $srv
$output = "$srv $ans"
$output | out-file "c:\windows\temp\PRTG.out" -append

exe powershell wmi

Created on Aug 19, 2021 2:44:36 PM

Last change on Aug 24, 2021 9:40:52 AM by  Moritz Heller [Paessler Support]



Best Answer

Accepted Answer

Votes:

0

Couple of things and this is now fixed.

  1. I used to use the parameter of %host when setting up the sensor
  2. $srv = $($args[0]) is what I used to capture the server name of the device that I want to run the sensor on.
  3. The PROBE itself, must be running as a user account that has access to do what you want the script to do. By default, the PROBE service is running as SYSTEM.

I now have a sensor to report back if patches have been applied in the last 30 days.

Created on Aug 24, 2021 11:07:03 AM

Last change on Sep 2, 2021 1:37:48 PM by  Moritz Heller [Paessler Support]



3 Replies

Votes:

0

Hi there,

did you already checked whether the parameter are correctly transferred to the script from PRTG? We recommend to use a "param" field to transfer values from PRTG to the script, e.g.:

 param(
    $args
  )

Created on Aug 24, 2021 9:57:47 AM by  Moritz Heller [Paessler Support]



Accepted Answer

Votes:

0

Couple of things and this is now fixed.

  1. I used to use the parameter of %host when setting up the sensor
  2. $srv = $($args[0]) is what I used to capture the server name of the device that I want to run the sensor on.
  3. The PROBE itself, must be running as a user account that has access to do what you want the script to do. By default, the PROBE service is running as SYSTEM.

I now have a sensor to report back if patches have been applied in the last 30 days.

Created on Aug 24, 2021 11:07:03 AM

Last change on Sep 2, 2021 1:37:48 PM by  Moritz Heller [Paessler Support]



Votes:

0

Hi Adam,

Thank you for the update.

Sounds like the Sensor works now. If you have a new issue with this Sensor, I recommend to open a ticket via an email to "[email protected]".

Created on Sep 2, 2021 1:38:54 PM by  Moritz Heller [Paessler Support]




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.