I'm attempting to create a sensor to report critical replication health of a VM from a probe device. I found another user who posted what seemed to be a fantastic solution, I'll include it below, however upon activating the sensor I get flagged by unexpected XML errors. I'm new to PRTG, so I'm doing my best to understand what's happening, but just don't get it. Any help would be appreciated.
# param([string]$Hypervserver) $Hypervserver = "HyperVHost" # $Session = New-PSSession -computername $Hypervserver $VMReplication = Get-VMReplication | select name,health,state $ErrMessage = " " $Errors = 0 $Warning = 0 $Critical = 0 foreach ($Name in $VMReplication) { if ($Name.Health -like "Normal" -and $Name.State -like "Replicating") { $state = 0 } elseif ($Name.Health -like "Warning") { $state = 1 $Warning = $Warning + 1 } elseif ($Name.Health -like "Critical") { $state = 1 $Critical = $Critical + 1 } $VM = $Name.Name $Health = $NAme.Health $Status = $Name.State $ErrMessage = $ErrMessage, $VM, " " , $Health , " ", $Status, "`t" $Errors = $Errors + 1 } If ($Errors = 0 ){ Write-Host 0 , ":OK", "Replicating is working fine" } elseif ($Critical = 1) { Write-Host 10 , ":", $ErrMessage } elseif ($Warning = 1) { Write-Host 5 , ":", $ErrMessage } else { Write-Host 2 , ":", $ErrMessage } #Added by mod Remove-PSSession -ID $Session.ID #Added by mod Exit 0