# Get event logs for specific date

**URL:** <https://forums.powershell.org/t/get-event-logs-for-specific-date/3613>\
**Category:** PowerShell Help\
**Created:** [January 12, 2015, 2:52am UTC](https://forums.powershell.org/t/get-event-logs-for-specific-date/3613 "2015-01-12T02:52:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nick-chard](https://avatars.discourse-cdn.com/v4/letter/n/e9bcb4/32.png) [@nick-chard](https://forums.powershell.org/u/nick-chard)\
**Post date:** [January 12, 2015, 2:52am UTC](https://forums.powershell.org/t/get-event-logs-for-specific-date/3613/1 "2015-01-12T02:52:36Z")

</div>

Hi,

I’m trying to list all event logs for a specific date

I’ve tried this, but it doesn’t return any results

```
Get-EventLog -LogName System | where { $_.timegenerated -like "10/01*" }
```

I can get events before or after a date by using this:

```
Get-EventLog -LogName System | where { $_.timegenerated -gt [get-date].AddDays[-7] }
Get-EventLog -LogName System | where { $_.timegenerated -lt [get-date].AddDays[-7] }
```

I guess it’s something to do with TimeGenerated being a System.DateTime object type, so maybe it should look a bit like this:

```
$date = New-Object -TypeName System.DateTime
Get-EventLog -LogName System | where { $_.timegenerated -eq $date }
```

I can’t work out how to assign the current date to $date, can someone point me in the right direction?

Thanks

---

<div class="post-metadata">

**Author:** ![will-anderson](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/will-anderson/32/234_2.png) [@will-anderson](https://forums.powershell.org/u/will-anderson)\
**Post date:** [January 12, 2015, 3:02am UTC](https://forums.powershell.org/t/get-event-logs-for-specific-date/3613/2 "2015-01-12T03:02:02Z")

</div>

Hey there Nick,

Try this:

Get-EventLog System | Where-Object TimeWritten -Like “12/12\*”

If you do a Get-EventLog System | Get-Member, it’ll give you the properties of the objects you’re retrieving. I also used Select-Object -First 1 to limit my selection to the first log entry so I didn’t have to swim through everything:

Get-EventLog System | Select-Object -First 1 | Get-Member

You’ll see that what you want to filter on is the TimeWritten property. Let me know if that helps!

---

<div class="post-metadata">

**Author:** ![richard-siddaway](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@richard-siddaway](https://forums.powershell.org/u/richard-siddaway)\
**Post date:** [January 12, 2015, 3:05am UTC](https://forums.powershell.org/t/get-event-logs-for-specific-date/3613/3 "2015-01-12T03:05:07Z")

</div>

Might be easier to use the -Before and -After parameters

Get-EventLog -LogName System -After (Get-Date -Date ‘1/1/2015’)  
Get-EventLog -LogName System -After (Get-Date -Date ‘1/1/2015’) -Before (Get-Date -Date ‘10/1/2015’)

---

<div class="post-metadata">

**Author:** ![will-anderson](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/will-anderson/32/234_2.png) [@will-anderson](https://forums.powershell.org/u/will-anderson)\
**Post date:** [January 12, 2015, 3:10am UTC](https://forums.powershell.org/t/get-event-logs-for-specific-date/3613/4 "2015-01-12T03:10:10Z")

</div>

Or that. 🙂

---

<div class="post-metadata">

**Author:** ![nick-chard](https://avatars.discourse-cdn.com/v4/letter/n/e9bcb4/32.png) [@nick-chard](https://forums.powershell.org/u/nick-chard)\
**Post date:** [January 12, 2015, 7:54pm UTC](https://forums.powershell.org/t/get-event-logs-for-specific-date/3613/5 "2015-01-12T19:54:55Z")

</div>

Hi, and thanks for your input. I found the problem, it’s to do with date format.

We use dd/mm/yy in the UK, and PowerShell displays dates in this format, so does Event Viewer. For some reason I have to use mm/dd/yy when I narrow down my results with where-object. I realised this when I searched using 12/12, as suggested by @Will Anderson, and it worked.

PS D:&gt; Get-EventLog -LogName System -newest 1 | where { $\_.TimeWritten -like “_2015_” } | select TimeWritten

## TimeWritten

13/01/2015 09:08:20

PS D:&gt; Get-EventLog -LogName System -newest 1 | where { $\_.TimeWritten -like “13/01/2015\*” } | select TimeWritten  
No Results

PS D:&gt; Get-EventLog -LogName System -newest 1 | where { $\_.TimeWritten -like “01/13/2015\*” } | select TimeWritten

## TimeWritten

13/01/2015 09:08:20

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:46pm UTC](https://forums.powershell.org/t/get-event-logs-for-specific-date/3613/6 "2024-05-16T20:46:32Z")

</div>


