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

XML Error code (PE233) - JSON Error code (PE231)

Votes:

0

I keep getting this error when trying to run a XML Custom EXE/Script Sensor:

"XML: The returned XML file does not match the expected schema. (code: PE233) -- JSON: The returned JSON file does not match the expected structure (Invalid JSON.). (code: PE231)"

My Script :

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
$exp_last_replication_file = Get-ChildItem '\\TEST\c$\TEST\REPLICATION_LOG' | Where {$_.LastWriteTime} | select -last 1
$exp_last_replication_file_name= $exp_last_replication_file.Name

$exp_last_replication_file_name_noext = $exp_last_replication_file_name.split(".")[0]
$exp_last_replication_date = $exp_last_replication_file_name_noext.split("_")[0]
$exp_last_replication_hour = $exp_last_replication_file_name_noext.split("_")[1]
$exp_last_replication_status = $exp_last_replication_file_name_noext.split("_")[2]
$exp_last_replication_diff = [System.Math]::Round(((Get-Date) - ($exp_last_replication_file.LastWriteTime)).TotalMinutes, 0)
if($exp_last_replication_status -eq "OK"){$ext_last_replication_status_nb = 0} else{$ext_last_replication_status_nb = 1}

$imp_last_replication_file = Get-ChildItem '\\TEST-BACKUP\c$\TEST\REPLICATION_LOG' | Where {$_.LastWriteTime} | select -last 1
$imp_last_replication_file_name= $imp_last_replication_file.Name
$imp_last_replication_file_name_noext = $imp_last_replication_file_name.split(".")[0]
$imp_last_replication_date = $imp_last_replication_file_name_noext.split("_")[0]
$imp_last_replication_hour = $imp_last_replication_file_name_noext.split("_")[1]
$imp_last_replication_status = $imp_last_replication_file_name_noext.split("_")[2]
$imp_last_replication_diff = [System.Math]::Round(((Get-Date) - ($imp_last_replication_file.LastWriteTime)).TotalMinutes, 0)
if($imp_last_replication_status -eq "OK"){$imp_last_replication_status_nb = 0} else{$imp_last_replication_status_nb = 1}

Write-Host "<?xml version=`"1.0' encoding=`'Windows-1252' ?><prtg><result><channel>1. TEST Replication Error - Export</channel><value>$ext_last_replication_status_nb</value></result><result><channel>2. FR-IOPS Last time Replication - Export</channel><value>$exp_last_replication_diff</value></result><result><channel>3. TEST Replication Error - Import</channel><value>$imp_last_replication_status_nb</value></result><result><channel>4. TEST Last time Replication - Import</channel><value>$imp_last_replication_diff</value></result><text>TEST Replication check sensor</text></prtg>"

custom-script help prtg windows

Created on Oct 11, 2022 8:20:41 AM

Last change on Oct 12, 2022 10:01:26 AM by  Felix Wiesneth [Paessler Support]



4 Replies

Votes:

0

Hi, please check if both 64 and 32 bit PowerShell Set-ExecutionPolicy is set to RemoteSigned or Unrestricted.

Created on Oct 15, 2022 9:35:06 AM



Votes:

0

Hello,

here is the output of the script with a message of "Modifying the execution strategy"

"Modifying the execution strategy The execution policy helps guard against scripts that you consider untrustworthy. By modifying the execution strategy, you expose yourself to the security risks described in the help topic about_Execution_Policies. Do you want to modify the execution strategy?"

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
$exp_last_replication_file = Get-ChildItem "\\fr-iops\c$\ALIECOM\REPLICATION_LOG" | Where {$_.LastWriteTime} | select -last 1
$exp_last_replication_file_name= $exp_last_replication_file.Name

$exp_last_replication_file_name_noext = $exp_last_replication_file_name.split(".")[0]
$exp_last_replication_date = $exp_last_replication_file_name_noext.split("_")[0]
$exp_last_replication_hour = $exp_last_replication_file_name_noext.split("_")[1]
$exp_last_replication_status = $exp_last_replication_file_name_noext.split("_")[2]
$exp_last_replication_diff = [System.Math]::Round(((Get-Date) - ($exp_last_replication_file.LastWriteTime)).TotalMinutes, 0)
if($exp_last_replication_status -eq "OK"){$ext_last_replication_status_nb = 0} else{$ext_last_replication_status_nb = 1}

$imp_last_replication_file = Get-ChildItem "\\fr-iops-backup\c$\ALIECOM\REPLICATION_LOG" | Where {$_.LastWriteTime} | select -last 1
$imp_last_replication_file_name= $imp_last_replication_file.Name
$imp_last_replication_file_name_noext = $imp_last_replication_file_name.split(".")[0]
$imp_last_replication_date = $imp_last_replication_file_name_noext.split("_")[0]
$imp_last_replication_hour = $imp_last_replication_file_name_noext.split("_")[1]
$imp_last_replication_status = $imp_last_replication_file_name_noext.split("_")[2]
$imp_last_replication_diff = [System.Math]::Round(((Get-Date) - ($imp_last_replication_file.LastWriteTime)).TotalMinutes, 0)
if($imp_last_replication_status -eq "OK"){$imp_last_replication_status_nb = 0} else{$imp_last_replication_status_nb = 1}

Write-Host "<prtg><result><channel>1. FR-IOPS Replication Error - Export</channel><value>$ext_last_replication_status_nb</value></result><result><channel>2. FR-IOPS Last time Replication - Export</channel><value>$exp_last_replication_diff</value></result><result><channel>3. FR-IOPS Replication Error - Import</channel><value>$imp_last_replication_status_nb</value></result><result><channel>4. FR-IOPS Last time Replication - Import</channel><value>$imp_last_replication_diff</value></result><text>FR-IOPS Replication check sensor</text></prtg>"
Get-ExecutionPolicy -List
MachinePolicy                                                                   RemoteSigned
UserPolicy                                                                      Undefined
Process                                                                      Undefined
CurrentUser                                                                   RemoteSigned
LocalMachine                                                                   RemoteSigned

Created on Oct 17, 2022 9:26:52 AM

Last change on Oct 17, 2022 9:58:30 AM by  Felix Wiesneth [Paessler Support]



Votes:

0

someone can help me please :)

Created on Oct 21, 2022 10:52:54 AM



Votes:

0

Hello, still relevant, if someone can help me

$exp_last_replication_file = Get-ChildItem -force "\\fr-iops\c$\ALIECOM\REPLICATION_LOG" | Where {$_.LastWriteTime} | select -last 1
$exp_last_replication_file_name= $exp_last_replication_file.Name

$exp_last_replication_file_name_noext = $exp_last_replication_file_name.split(".")[0]
$exp_last_replication_date = $exp_last_replication_file_name_noext.split("_")[0]
$exp_last_replication_hour = $exp_last_replication_file_name_noext.split("_")[1]
$exp_last_replication_status = $exp_last_replication_file_name_noext.split("_")[2]
$exp_last_replication_diff = [System.Math]::Round(((Get-Date) - ($exp_last_replication_file.LastWriteTime)).TotalMinutes, 0)
if($exp_last_replication_status -eq ":OK"){$ext_last_replication_status_nb = 0} else{$ext_last_replication_status_nb = 1}

$imp_last_replication_file = Get-ChildItem -force "\\fr-iops-backup\c$\ALIECOM\REPLICATION_LOG" | Where {$_.LastWriteTime} | select -last 1
$imp_last_replication_file_name= $imp_last_replication_file.Name
$imp_last_replication_file_name_noext = $imp_last_replication_file_name.split(".")[0]
$imp_last_replication_date = $imp_last_replication_file_name_noext.split("_")[0]
$imp_last_replication_hour = $imp_last_replication_file_name_noext.split("_")[1]
$imp_last_replication_status = $imp_last_replication_file_name_noext.split("_")[2]
$imp_last_replication_diff = [System.Math]::Round(((Get-Date) - ($imp_last_replication_file.LastWriteTime)).TotalMinutes, 0)
if($imp_last_replication_status -eq ":OK"){$imp_last_replication_status_nb = 0} else{$imp_last_replication_status_nb = 1}

Write-Host "<prtg>
<result>
<channel>1. FR-IOPS Replication Error - Export</channel>
<value>$ext_last_replication_status_nb</value>
</result>
<result>
<channel>2. FR-IOPS Last time Replication - Export</channel>
<value>$exp_last_replication_diff</value>
</result>
<result>
<channel>3. FR-IOPS Replication Error - Import</channel>
<value>$imp_last_replication_status_nb</value>
</result>
<result>
<channel>4. FR-IOPS Last time Replication - Import</channel>
<value>$imp_last_replication_diff</value>
</result>
<text>FR-IOPS Replication check sensor</text>
</prtg>"

Created on Oct 28, 2022 8:18:01 AM

Last change on Oct 31, 2022 7:23:57 AM 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.