### 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!

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

View all Tags

# Custom Sensor Powershell

#### 0

Hello,

I would like to monitor the age of a folder, instead of the files in the folder. We are using Robocopy to keep a folder up to date. Now we want to use a custom sensor wich checks the age of that folder (wich exists only on a few workstations) and trigger a warning if the Backup failed on one or more workstations.

i'm using a simple Powershell query (Get-ChildItem -Path "
PCNAME\C\$\Folder\to\Monitor\" | Select LastWriteTime, Name) wich works great in Powershell:

LastWriteTime Name ------------- ---- 27.04.2021 16:35:22 A1 27.04.2021 15:31:17 A2 27.04.2021 15:46:44 B1 27.04.2021 15:56:47 B2 27.04.2021 16:13:12 C1 27.04.2021 16:24:54 C2 27.04.2021 16:32:01 D2 27.04.2021 16:32:23 TK 

But it doesnt work as expected, because i get an error: response not well-formed: "( )" (Code: PE132).

Created on Jun 16, 2021 1:38:28 PM by BDH Admin (0) 1

3 Replies

#### 0

Hello,

Are you trying to send the last modified timestamp to PRTG? That will not work as that is a string, and PRTG can only show string values in the message field of the sensor. What you need to do is take the most recent timestamp, and have your script do a difference from the current time to that timestamp. You can then take the hours, minutes, or seconds difference, and pass that along to PRTG as the age of the folder. With that value, PRTG can use it just like the file sensor measures the age of files.

Benjamin Day
[Paessler Support]

Created on Jun 16, 2021 2:07:04 PM by

#### 0

Thank you for the fast reply, i changed my PS Query and and in PRTG i got kinda a broken timestamp. the modified date from one of the folders is: Mittwoch 16. Juni 2021 10:40:34 but the sensor shows only 40:34.

I found a different topic about that problem that the sensor doesnt know where the message or the value starts, but i cant find it anymore.

and how can i setup the channel to compare the output with the actual time?

Created on Jun 16, 2021 2:49:41 PM by BDH Admin (0) 1

#### 0

The sensor will not do the comparison. The script needs to compare and return the amount of time in whichever unit you prefer. Then PRTG is just handling an amount of time that you can specify a threshold against. Does this make sense?

Benjamin Day
[Paessler Support]

Created on Jun 17, 2021 4:02:38 PM by