Get Windows Eventlog entries by a date in PowerShell

I am trying to filter eventlogs in PowerShell by a date range. When I run the command, it shows every event log by the entry type that I give. What am I doing wrong?

Get-EventLog -LogName System -EntryType Error -Before 12/1/19 -After 12/3/19

1 Answer

Windows 10 64-bit. Powershell 5.

By the logic of your question you want the entries except for 12/02 but I am including two methods in case your question was wrong.

powershell get-eventlog by specific date:

Get-EventLog System -Entrytype Error | Where-Object TimeWritten -Like "12/02/2019*"

or:

powershell get-eventlog before date and after date:

Get-EventLog System -Entrytype Error -Before 12/01/2019 -After 12/03/2019

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like