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





