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