PE233 and PE231 Error with a Powershell Script for a Custom XML Sensor (EXE/Script Advanced) for PRTG Network Monitor

Recently I wrote a Powershell sensor for PRTG and wanted to use it as EXE/Script Advanced sensor on a Windows 10 Home (Build 1607) Probe system.

So I copied my xyz.ps1 file into the correct folder:

C:\Program Files\PRTG Network Monitor\Custom Sensors\EXEXML

Then I created a new EXE/Script Advanced Sensor and selected xyz.ps1 as my Script.

But when the sensor ran for the first time I got the message:

XML: The returned XML does not match the expected schema. (code: PE233) — JSON: The returned JSON does not match the expected structure (No mapping for the Unicode character exists in the target multi-byte code page). (code: PE231)

The reason is that Powershell didn’t actually execute the sensor code but gave back the following error message (which obviously PRTG couldn’t interpret at XML):

File C:\Program Files\PRTG Network Monitor\Custom Sensors\EXEXML\xyz.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at + CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnauthorizedAccess

To fix this I had to allow 32-bit Powershell Scripts to be run on the probe system (Windows 64-bit) by executing the following command in a command-line-window (cmd.exe) with admin rights (see Paessler knowledge base):

%SystemRoot%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe "Set-ExecutionPolicy RemoteSigned"

BTW, running the same command on 64-bit systems sets the same setting for 64-bit powershell, but since PRTG always runs powershell scripts in 32-bit, this is not enough.

powershell.exe "Set-ExecutionPolicy bypass" 

There might be more secure settings, that also work, but I didn’t bother with that.

Now my Powershell script works fine.

Author: Dirk Paessler

CEO Carbon Drawdown Initiative -- VP Negative Emissions Platform -- Founder and Chairman Paessler AG

3 thoughts on “PE233 and PE231 Error with a Powershell Script for a Custom XML Sensor (EXE/Script Advanced) for PRTG Network Monitor”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s