We help IT Professionals succeed at work.

Filter Event log CSV for certain TIME

I am working with the Security Event Log CSV, and what I am trying to figure how to do is filter out based on the TIME column. What I want to be able to do is only see information between the hours of 18 (6:00 pm) and 7:00am the next day (after hours).
CSV is formatted as
Type,Date,Time,Source,Category,Event,User,Computer
Time column is formatted as: 10:15:25 PM
Comment
Watch Question

PowerShell Developer
Top Expert 2010
Commented:

It should be possible if we make the Time into a System.DateTime object then pull and test the Hour Property. e.g.


Import-Csv "File.csv" | ?{ ([DateTime]($_.Time)).Hour -gt 18 -Or  ([DateTime]($_.Time)).Hour -lt 7 }


HTH

Chris

Author

Commented:
Bingo - your the man. Thanks