Eu provavelmente usaria apenas Get-Date
e comparei como DateTime
objects. O seguinte retornará True
usando seus valores fornecidos.
$evtOne = Get-WinEvent -FilterHashtable @{logname='ScriptEvents'; id=1} -MaxEvents 1
$evtTwo = Get-WinEvent -FilterHashtable @{logname='ScriptEvents'; id=0} -MaxEvents 1
(Get-Date $evtOne.TimeCreated) -lt (Get-Date $evtTwo.TimeCreated)