I have a Powershell Script:

(Get-Counter @("\Terminal Service Gateway\Current connections") -ComputerName "10.182.2.20").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
37

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?

Thanks


Article Comments

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:
<count>:<message>

For example:
1:1 Connection

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


Apr, 2020 - Permalink