Ad Widget

Collapse

monitor windows updates for zabbix .

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aviad
    Junior Member
    • Oct 2020
    • 17

    #1

    monitor windows updates for zabbix .

    Hello all,
    i am trying for a long time to monitor al my windows server if they are up to date on the last update of there is pending updates.


    i build the following PowerShell script:
    $AllUpdates= @()
    $AllObjects = @()

    #Check for update
    $WUcheck = Get-WUList
    $KBs = $WUcheck |select KB |where {$_.KB -Match "KB"}
    $UpdateName = $WUcheck |select Title |where {$_.Title -match "(KB)"}
    $Updates = $WUcheck |select KB, Title |where {$_.KB -Match "KB" }

    if ($WUcheck -eq $null){
    $obj = New-Object PSCustomObject
    Add-Member -InputObject $obj -MemberType NoteProperty -Name "UPNAME" -Value $Null
    Add-Member -InputObject $obj -MemberType NoteProperty -Name "UPNUMBER" -Value 0
    $AllObjects += $obj

    }

    else{

    foreach ($Update in $Updates){
    $obj = New-Object PSCustomObject
    Add-Member -InputObject $obj -MemberType NoteProperty -Name "UPNAME" -Value $Update.Title
    Add-Member -InputObject $obj -MemberType NoteProperty -Name "UPNUMBER" -Value $Update.KB
    $AllObjects += $obj
    }

    }


    $AllObjectsJSON = $AllObjects| select @{N='{#UPNAME}'; E={$_.UPNAME}},@{N='{#UPNUMBER}'; E={$_.UPNUMBER}}
    write-host "{"
    write-host " `"data`":`n"
    convertto-json $AllObjectsJSON
    write-host "}"



    on zabbix i am getting the the following error attach
    the user parameter that i am using is :

    UserParameter=GetPendingUpdates[*],%SystemRoot%\system32\WindowsPowerShell\v1.0\powe rshell.exe -nologo -command “& "c:\Program Files\Zabbix Agent\scripts\check Windows Update for zabix.ps1" $1”

    please help to solve this.


    Attached Files
  • Aviad
    Junior Member
    • Oct 2020
    • 17

    #2
    Anyone know how to fix this ?

    Comment

    • Hamardaban
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • May 2019
      • 2713

      #3
      The error indicates that you have the wrong json and something is wrong with the pair of parentheses. Check that the script returns the correct data when executed.

      Comment

      • Aviad
        Junior Member
        • Oct 2020
        • 17

        #4
        manage to fix this
        thanks

        Comment

        Working...