New Question
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

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

Download >>


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!

Learn more


Top Tags

View all Tags

Guide For PowerShell Based Custom Sensors



Your Vote:



I have a PowerShell script, either from the Knowledge Base, from Support or somewhere from the internet. I'm a bit lost, though. How do I install this and what do I need to do in order to get it to work properly?

console executionpolicy powershell script sensors

Created on Sep 22, 2016 7:52:27 AM by  Stephan Linke [Paessler Support]

Last change on Sep 22, 2016 9:19:05 AM by  Stephan Linke [Paessler Support]

3 Replies

Accepted Answer



Your Vote:



This article applies to PRTG Network Monitor 16 or later

Guide For PowerShell Based Custom Sensors

Do not worry, we guide you through the installation of PowerShell scripts to PRTG. Simply follow these steps:

1. Configure the Execution Policy of the PRTG Server

The execution policy configured on a host specifies what scripts can be executed on the Windows host. There are several available settings for that:

RestrictedNo scripts can be executed directly, only within an interactive session.
AllSignedOnly scripts from a trusted author can be executed.
RemoteSignedDownloaded scripts have to be signed prior to execution.
UnrestrictedNo restrictions, all codes will be executed.

By default, the execution policy is set to Restricted. It will hinder PRTG from executing scripts, therefore we cannot use them.

We need to set it first. Because the scripts are always executed by the PRTG Probe service (the PRTG Probe is a 32 bit application), we need to use the 32 bit PowerShell:

  1. Open Windows PowerShell (x86), respectively Windows PowerShell (32bit) as Administrator.
  2. Set the ExecutionPolicy to RemoteSigned with the following command:
    Set-ExecutionPolicy RemoteSigned
  3. Remember that when the device is located on a remote probe, you need to do the steps on the Remote Probe system, not on the PRTG Core Server system.
    That's it actually. Let's proceed to the next step. Note that you need to do this only once.

2. Install the PowerShell Script

Next, we'll have to check the output of the script. We only have two options here:

One lineEXE/Script<PRTG Application Directory>\Custom Sensors\EXE\
XMLEXE/Script (Advanced)<PRTG Application Directory>\Custom Sensors\EXEXML\

If you already know the output type, simply copy the script to the corresponding directory.
Make sure it has .ps1 as extension. However, if it's unsure what kind of script you have, you have two options:

  1. Open up the script and search for something like Write-Host or Out-Host
  2. If the output looks like XML, place the script into the EXEXML folder.
    Otherwise, place it into the EXE folder.

3. Test the Script

Okay, the script is now installed. But how do we use it correctly? If the script is documented properly (either via PowerShell or text documentation), this should be no problem. You can show the PowerShell help for a script like that:

Get-Help <path-to-the-script> -detailed

It will show you a description of the script and what parameters are supported including their description. If the script lacks documentation entirely, simply open up the script within an editor and search for param. The parameters are listed there. You can then call the script either like this:
-parameter1 <testvalue> -parameter2 <testvalue2> You can omit the parameters if you enter them in the correct order. If the script works fine, you can proceed with creating the sensor in PRTG.

4. Create the Sensor in PRTG

Open up the device that you want to add the sensor to and add a new sensor, choose EXE/Script or EXE/Script (Advanced).

EXE/ScriptSelect the script you have just installed.
ParametersEnter the parameters. Remember that you can use the placeholders here.
Security ContextChose if you want the script to be run using the user account of the probe service or the one configured in the device.
Mutex NameIf you have many sensors that run concurrently, you can configure different mutex names, so they don't hinder each other.

That's it, you're done!

First Aid

ProblemResponse not well formed: "(File C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\test.ps1 cannot be loaded because the execution of scripts is disabled on this system."
Solution1The execution policy is not configured correctly on the host. Go through Step 1 of this tutorial to resolve this.
Solution2Double check that the downloaded script-file is not "Blocked". Right-click the script file, on the General tab you'll see: "This File came from another computed and might be blocked to help protect this computer." Click "Unblock".
ProblemThe sensor shows UnauthorizedAccess.
SolutionThis is probably due to the user account configured in the probe service or device, depending on what you selected as security context. Make sure that the user has all permissions necessary to execute the sensor properly.
ProblemThe term '<insert-cmdlet-name-here>' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
SolutionThis indicates that either a command or function used by the script is not declared properly within the script or that it uses a cmdlet that is not available on the PRTG server. Most likely, the latter one is the case. Please make sure that you're running the latest Windows Management Framework.
ProblemThe sensor displayed incorrect results (0) or no values after migrating the sensors to a new/different server/windows version. You may also get: XML: Junk after document element </text> -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231) error messages.
SolutionKeep in mind that newer operating systems will usually run a newer powershell version, your cmdlets may be missing parameters or your variables may not be correctly called within text ($($var) instead of $var). Run the script from the command-line to confirm that it still works or adjust it if necessary.

Created on Sep 22, 2016 9:16:26 AM by  Stephan Linke [Paessler Support]

Last change on Nov 30, 2018 6:38:31 AM by  Sebastian Kniege [Paessler Support]



Your Vote:



Could you by any chance provide a guide on creating lookup files to turn standard xml output into something PRTG can understand?

Created on Jan 12, 2018 3:00:47 PM by  Samuel Ashdown (60) 1 1



Your Vote:



Hey Sam,

You might want to check the REST Custom Sensor, as it allow you to properly evaluate XML/JSON into PRTGesque channels :) Or do you require assistance with that?

Kind regards,
Stephan Linke, Tech Support Team

Created on Jan 15, 2018 7:28:56 AM by  Stephan Linke [Paessler Support]

Please log in or register to enter your reply.

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.