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

Weird behaviour POWERSHELL script data returned to PRTG

Votes:

0

Hello,

I'm testing a simple Powershell script, and the behaviour is rather stranger.

My script is:

$pathcounter = (Get-ChildItem -Path C:\Windows).count
Write-Host $pathcounter
 
#returning PRTG XML data
"<prtg>"
        "<result>"
        "<channel>Nombre d'ojets dans C:\Windows </channel>"
        "<value>$pathcounter</value>"
        "</result>"
"</prtg>"

This script return the right value in PRTG.

If I change the first line with

$pathcounter = (Get-ChildItem -Path \\MYSERVER\C$\Windows).count

the value returns 0 to PRTG, although the $pathcounter is correctly set and match the content of C:\Windows on MYSERVER.

If I execute the script in a Powershell editor the <value>xxx</value> is set correctly and match the content of the $pathcounter variable.

What is the reason the script return 0 to PRTG ?

Thanks for the answer.

powershell prtg script

Created on Jan 9, 2023 4:35:46 PM

Last change on Jan 10, 2023 12:49:10 PM by  Felix Wiesneth [Paessler Support]



3 Replies

Votes:

0

Hi there,

Did you already checked the exact data returned from the script? You can do this via the "Result Handling" option of the Sensor? It's possible that more errors were reported but PRTG only displays 0

Created on Jan 11, 2023 3:07:57 PM by  Moritz Heller [Paessler Support]



Votes:

0

Thank you for the answer, I have a little problem, I activated the log creation for the sensor, but the LOGS/SENSORS directory is missing on my PRTG server. I did not find the way to activate log sensor file creation in the administration tools.

Any idea ?

Created on Jan 11, 2023 3:56:41 PM



Votes:

0

The result handling option is located in the Sensor settings. The log directory is in the PRTG data directory: https://kb.paessler.com/en/topic/463-how-and-where-does-prtg-store-its-data

Created on Jan 13, 2023 9:44:52 AM 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.