How can I query windows server events between two times of any day? I have tried with PowerShell...
Get-EventLog -Logname xxxx -After 04:00:00 -Before 04:00:30
...but just returns today's events
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.
Sign up to join this communityTo find events between two times at any day we'll want to use a regex. Example code to find any event that happened between 04:00:00 and 04:29:59 of any day in the System log:
Get-EventLog -LogName System | ?{$_.TimeGenerated -match "04:[0-2][0-9]:[0-5][0-9]"}
04:[0-2][0-9]:[0-5][0-9]
)? for example if my time range is 04:00:55 - 05:12:03
then how to modify the regex?