Hello,
Thank you for your message.
You can indeed developed a script to count the number of specific events on a target machine and monitor that value with PRTG.
To do so, you need to execute the command remotely on the target device and provide all the information you need to the script from PRTG via the parameter fields. For example, you can pass the Windows credential to the script with the following parameters/line of code:
"%host" "%windowsuser" "%windowspassword"
Param (
[string]$host = "",
[string]$winuser = "",
[string]$winpass = ""
)
A credential object will be necessary to use Get-WinEvent on target devices by adding -Credential to that command. Here is an article which explains on how to create this object in PowerShell:
https://adamtheautomator.com/powershell-get-credential/
The script must also return the value by following the format indicated in this manual: https://www.paessler.com/manuals/prtg/custom_sensors. In this case, as you only have one value, the format is "value:message". You can use the following command to return the data in PRTG (with variables replaced accordingly):
Write-Output "{0}:{1}" -f $value, $message
Regards.
Add comment