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

Error when add a Custom Sensor with Powershell Script



I have a Powershell Script:

(Get-Counter @("\Terminal Service Gateway\Current connections") -ComputerName "").CounterSamples.CookedValue

When i run it on PRTG Server, it return result normal:

PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE> .\RDPGWSession.ps1

But when i add to prtg custom sensor it error:

Custom EXE/Script Sensor

Response not well-formed: "(Get-Counter : Unable to access the desired computer or service. Check the permissions and authentication of the log service or the interactive user session against those on the computer or service being monitored. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\RDPGWSession.ps1:1 char:2 + (Get-Counter @("\Terminal Service Gateway\Current connections") -ComputerName "1 ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ + CategoryInfo : InvalidResult: (:) [Get-Counter], Exception + FullyQualifiedErrorId : CounterApiError,Microsoft.PowerShell.Commands.Ge tCounterCommand )" (code: PE132)

How to fix it?


custom-sensor prtg terminal-service-gateway

Created on Apr 8, 2020 5:00:37 AM

Last change on Apr 8, 2020 5:45:09 AM by  Sven Roggenhofer [Paessler Technical Support]

1 Reply



First, you'd need to use Invoke-Command and Remote PowerShell to execute the Get-Counter cmdlet on the PRTG Server itself. Get-Counter on itself doesn't provide any credentials it could use for login.

Additionally, you'd need to use a different output syntax:

For example:
1:1 Connection

On the other hand, couldn't you use the WMI Terminal Services Sensor instead?

Created on Apr 8, 2020 2:32:42 PM by  Stephan Linke [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.