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

Create powershell script for sensor

Votes:

0

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>"
   }

powershell script sensors

Created on May 5, 2022 7:29:15 AM

Last change on May 5, 2022 2:09:25 PM by  Felix Wiesneth [Paessler Support]



3 Replies

Votes:

0

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

Created on May 6, 2022 7:12:14 AM by  Timo Dambach [Paessler Support]



Votes:

0

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

Created on May 6, 2022 7:37:15 AM



Votes:

0

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.

Created on May 9, 2022 7:30:02 AM by  Timo Dambach [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.