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>"
Article Comments
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
Oct, 2022 - Permalink
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>"
Oct, 2022 - Permalink
Hi, please check if both 64 and 32 bit PowerShell Set-ExecutionPolicy is set to RemoteSigned or Unrestricted.
Oct, 2022 - Permalink