Hello, please i need to create a simple powershell script for check the last modified time of a folder, then if is upper 24 ours get an alert, and if is under 24 ours it's ok. I can get the last time but i don't know how to get the alert on sensor

Get-Item C:\prova | select LastWriteTime
 if $result
     {
    write-host "<prtg>"
    write-host "<result>"
    write-host "<channel>Ultima modifica</channel>"
    write-host "<value>$data</value>"
    write-host "</result>"
    write-host "<text>Error in logfile</text>"
    write-host "</prtg>"
   }

Article Comments

Attention: This article is a record of a conversation with the Paessler support team. The information in this conversation is not updated to preserve the historical record. As a result, some of the information or recommendations in this conversation might be out of date.

Hello,

Assuming the script is working fine and you are able to display the last modified time in PRTG using the custom EXE sensor, you can simply add a "Upper Error Limit" of 24 hours in the channel settings. Then the sensor will show an error/down state if the value is above 24 hours. Also have a look here: https://www.paessler.com/support/how-to/limits


May, 2022 - Permalink

Hello, my problem is the script that i don't know how to write for have the result in custom EXE sensor...


May, 2022 - Permalink

The result syntax seems fine already. However if that is the whole script, it seems like there's no value for the "$data" parameter. Please also check if you can run the script manually to get the proper XML result - if this works, the sensor should as well.


May, 2022 - Permalink