PowerShell: count the Windows EventLog entries for Applications over the last 10 minutes
Posted by jpluimers on 2019/09/25
In production, somehow an application started to misbehave, so would spit out a lot of Windows EventLog entries for Applications you can see in the EventViewer. This small script helped counting it (it takes about 10 seconds on a log having a total of 77k entries):
$tenMinutes = New-TimeSpan -Minutes 10
$now = Get-Date
$tenMinutesAgo = $now - $tenMinutes
$eventLogEntries = Get-EventLog -After $tenMinutesAgo -LogName "Application"
$count = ($eventLogEntries | Measure-Object).Count
Write-Host $count
Related:
- [WayBack] Get-Date (Microsoft.PowerShell.Utility)
- [WayBack] Get-EventLog (Microsoft.PowerShell.Management)
- [WayBack] Measure-Object (Microsoft.PowerShell.Utility)
- [WayBack] New-TimeSpan (Microsoft.PowerShell.Utility)
- [WayBack] Write-Host (Microsoft.PowerShell.Utility)
–jeroen
Ruurd said
I don’t know who came up with this shit…