Ad Widget

Collapse

eventlog and parsing xml

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zveky
    Junior Member
    • Feb 2014
    • 2

    #1

    eventlog and parsing xml

    Hi,

    ver. 2.4
    windows 2008/2012

    is it possible to filter xml part of event log, does anyone have idea how to do that?

    For example I would like to filter Microsoft-Windows-Backup log for event ID 14 and search for HRESULT part because if different then 0 something happened with backup and need to be checked.

    Now I do this with a script but would like if possible to do with out of the box feature.

    #script sample

    $events=Get-WinEvent -logname 'Microsoft-Windows-Backup' -MaxEvents 1 -FilterXPath 'Event[System[EventID=14 and TimeCreated[timediff(@SystemTime) <= 86400000]]]'
    $event = [xml]$events.ToXml()
    $hresult = $event.Event.EventData.Data[1].'#text'

    If ($hresult -eq "0x0") {Write-Host 0} else {Write-Host 1}

    Regards,
    Darko Bazulj
Working...