Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get-EventLog - easily filter by 'today'?

I want to quickly check for events that happened today (that is: anything from midnight onwards); is there 'today' alias/built-in in Powershell to help out with this ?

I'm currently doing something like this:

get-eventlog system  -source "disk" -after ([datetime] '01/01/2015')

But of course I keep having to change the date string.

[ Also: that datetime constructor appears to insist on a US date-format (mm/dd/yyyy) only - despite the fact that my Windows Locale is UK ?]

like image 283
monojohnny Avatar asked Apr 11 '16 13:04

monojohnny


Video Answer


1 Answers

The DateTime class has a static Property Today which will return exactly what you need:

get-eventlog system  -source "disk" -after ([datetime]::Today)
like image 163
Martin Brandl Avatar answered Oct 21 '22 01:10

Martin Brandl