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

Issues with PowerShell return values



Hi there,

I'm running into issues regarding PowerShell return values. I'm using a PS script to detect whether Windows processes are responding or not.

Here's the code:


$check_result = [string](gps -name $p_name).Responding


if($check_result -like "*False*"){
    $exit_code = 4
    write-host $exit_code":Error (At least one associated process is not responding)"
    exit 4
elseif($check_result -notlike "*False*"){
    $exit_code = 0
    write-host $exit_code":OK (All associated processes are responding)"
    exit 0

For testing purposes, I'm opening a couple of instances of notepad or calc and suspend some of them in Resource Monitor. The script itself is working fine and I get the expected results, but only as long as I run it directly on the server in the "normal" PowerShell or ISE, respectively. But when I add it as a sensor, it always returns "All associated processes are responding", no matter whether there really are any processes not responding or not. It seems like it always immediately jumps to the "elseif" part.

I'm running PRTG on Windows Server 2016. Can you please let me know, if my code is just not right (I'm quite new to PowerShell) or I haven't understood something correctly stated in the manual? I'm sure, I must have overlooked something ...

Thanks in advance and best regards, Matthias

powershell prtg value

Created on Jul 10, 2020 1:30:16 PM

Last change on Jul 10, 2020 1:33:35 PM by  Felix Wiesneth [Paessler Support]

1 Reply



Hello Matthias,

I would recommend you our guide for PowerShell-based sensors. In addition I would recommend to take a look at our Windows Process sensor. This sensor might display the same and it's a native sensor.

Kind regards

Felix Wiesneth - Team Tech Support

Created on Jul 10, 2020 1:45:24 PM by  Felix Wiesneth [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.