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

Strange problem

Votes:

0

Hi, where is the problem?

My Code:

Param
(
    [String]$hvHost
)

set-item wsman:\localhost\Client\TrustedHosts -value $hvHost -Force
$password = ConvertTo-SecureString "xxxxx" -AsPlainText -Force
$user = "LAIAUTO\support"
$cred = New-Object System.Management.Automation.PSCredential ($user,$password)
$s = New-PSSession -ComputerName $hvHost -Credential $cred

Invoke-Command -Session $s{

# -----------------------

$CurrentDate = (Get-Date)

$Results = Get-VMReplication | Select VMName, VMId, ReplicationMode, ReplicationHealth, ComputerName,`
                                             PrimaryServer, ReplicaServer, LastReplicationTime, ReplicationState `
                                             | Where-Object ReplicationMode -eq "Primary"


$xmlstring = "<?xml version=`"1.0`"?>`n    <prtg>`n"

ForEach ($eachresult IN $Results) {

$TotalMinutes = (New-Timespan –Start $eachresult.LastReplicationTime –End $CurrentDate).TotalMinutes

$xmlstring += "    <result>`n"
$xmlstring += "        <channel>$($eachresult.VMname)</channel>`n"
$xmlstring += "        <unit>Custom</unit>`n"
$xmlstring += "        <CustomUnit>min</CustomUnit>`n"
$xmlstring += "        <mode>Absolute</mode>`n"
$xmlstring += "        <showChart>1</showChart>`n"
$xmlstring += "        <showTable>1</showTable>`n"
$xmlstring += "        <float>0</float>`n"
$xmlstring += "        <value>$(IF ($TotalMinutes -lt 1) {"0"} ELSE {IF ($TotalMinutes -le 60) {$TotalMinutes.ToString("#")} ELSE {"60"}})</value>`n"
$xmlstring += "        <LimitMaxError>59</LimitMaxError>`n"
$xmlstring += "        <LimitMaxWarning>20</LimitMaxWarning>`n"
$xmlstring += "        <LimitWarningMsg>Hyper-V Replication for this VM is in Warning state</LimitWarningMsg>`n"
$xmlstring += "        <LimitErrorMsg>Hyper-V Replication failed for this VM and is in Critical state</LimitErrorMsg>`n"
$xmlstring += "        <LimitMode>1</LimitMode>`n"
$xmlstring += "    </result>`n"

 }

$xmlstring += "    </prtg>"

Write-Host $xmlstring
}


If I run this on PS console work fine
PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML> .\Replica.ps1 -hvHost 10.55.55.137
<?xml version="1.0"?>
    <prtg>
    <result>
        <channel>VM2019OR-01 (SALONE)</channel>
        <unit>Custom</unit>
        <CustomUnit>min</CustomUnit>
        <mode>Absolute</mode>
        <showChart>1</showChart>
        <showTable>1</showTable>
        <float>0</float>
        <value>2</value>
        <LimitMaxError>59</LimitMaxError>
        <LimitMaxWarning>20</LimitMaxWarning>
        <LimitWarningMsg>Hyper-V Replication for this VM is in Warning state</LimitWarningMsg>
        <LimitErrorMsg>Hyper-V Replication failed for this VM and is in Critical state</LimitErrorMsg>
        <LimitMode>1</LimitMode>
    </result>
    </prtg>

But my PRTG server send me error

Sensor XML Custom EXE/Script Sensor

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)

And log file is:

A command that prompts the user for information failed because the host program or command type does not support user interactions. Try a host program that supports such interactions, such as the Windows PowerShell console or Windows PowerShell ISE, and remove prompt-related commands from command types that don't support user interactions, such as Windows PowerShell workflows.

Whre is the problem????? Ty

exe-xml ps script

Created on Jun 25, 2021 8:49:33 AM

Last change on Jun 25, 2021 9:05:46 AM by  Felix Wiesneth [Paessler Support]



3 Replies

Votes:

0

Hello,

Just to make sure, are you using the Exe/Script or Exe/Script Advanced sensor?
The Output your scripts provides is formatted for the Exe/Script Advanced sensor (EXEXML folder in PRTG).

If you are already using the Advanced sensor, you can check under what security context the sensor runs in its Settings tab. We recommend to use the Windows credentials of the parent device, and in the device have the same user configured that you used to run the script manually.


Kind regards,
Sasa Ignjatovic, Tech Support Team

Created on Jun 25, 2021 9:39:53 AM by  Sasa Ignjatovic [Paessler Support]



Votes:

0

I have the same, identic, problem with Exe/Script or Exe/Script Advanced sensor Same, identic

Security context is correct to Windows credentials.

the scripts worked until yesterday i updated the prtg server to the latest version

Created on Jun 25, 2021 9:48:17 AM



Votes:

0

In this case, I would recommend that you open a support ticket. You can do this by sending a email at [email protected].

When you open the ticket it would be good to include screenshots of the Overview, Log and Settings tab of the sensor.


Kind regards,
Sasa Ignjatovic, Tech Support Team

Created on Jun 25, 2021 10:15:45 AM by  Sasa Ignjatovic [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.