Why does this work for -liit but not -ge or -gt??


get-eventlog -log application -source foo | where-object { $_.creationtime -ilt [datetime]::now.adddays(-1) }

works lt not ge or gt -- need code pull events within last 1 day occurrence.

when use -ge or -gt no listing @ all, why??

thank you, tom

what version of powershell using? have win2008r2 ps2 , works

ps c:\users\administrator> $now
donnerstag, 7. juli 2011 20:04:04
ps c:\users\administrator> $now.addminutes(-15)
donnerstag, 7. juli 2011 19:49:04
ps c:\users\administrator> get-eventlog -log "application" -entrytype error -after $nowminusfifteen -before $now

   index time          entrytype   source                 instanceid message
   ----- ----          ---------   ------                 ---------- -------
  411327 jul 07 20:00  error       microsoft-sharepo...         6540 description event id '2137' in source '...

 

 

why need gt when have before , after specify timerange?



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Edit Group Policy

Hyper-V VM not reaching OS 'Logon' screen

DNS question...