Ad Widget

Collapse

Powershell Discovery JSON error. ( own template remake)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BartTechne
    Junior Member
    • Jan 2019
    • 15

    #1

    Powershell Discovery JSON error. ( own template remake)

    Hi,

    I am trying to get a Powershell working inside a 4.2.1 zabbix. The template used to be made for an old evn. Its a discovery service

    Original Content: https://share.zabbix.com/operating-s...cal-drive-iops

    The powershell + Result:

    $drives = Get-WmiObject win32_PerfFormattedData_PerfDisk_PhysicalDisk | ?{$_.name -ne "_Total"} |
    Select Name;$idx = 1;write-host "{";write-host " `"data`":[`n";foreach ($perfDrives in $drives){if ($idx -lt $drives.Count){
    $line= "{ `"{#DISKNUMLET}`" : `"" + $perfDrives.Name + "`" },";write-host $line;}elseif ($idx -ge $drives.Count){$line= "{ `"{#DISKNUMLET}`"
    : `"" + $perfDrives.Name + "`" }";write-host $line;}$idx++;};write-host;write-host "]";write-host "}";


    {
    "data":[

    { "{#DISKNUMLET}"
    : "0 C:" }

    ]
    }

    Even though i run this in a Json Validator and it comes out Validated. I get the following errors:

    Invalid discovery rule value: cannot parse as a valid JSON object: invalid object format, expected opening character '{' or '[' at: '#< CLIXML
    {
    "data":[

    { "{#DISKNUMLET}" : "0 C: D:" }

    ]
    }
    <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="p

    Key:

    system.run[%SystemRoot%\system32\WindowsPowerShell\v1.0\power shell.exe -executionpolicy ByPass -nologo -EncodedCommand {$DISCOVERDISK1}{$DISCOVERDISK2}{$DISCOVERDISK3}{$ DISCOVERDISK4}{$DISCOVERDISK5}]
    Last edited by BartTechne; 03-05-2019, 11:49.
Working...