IT Toolbox

Search for critical errors in the last 24 hours

View my favorites
PowerShell Low risk Administrator required

Search for critical errors in the last 24 hours

Extracts errors and critical events from System and Application logs over the last 24 hours.

Command / script
$Depuis = (Get-Date).AddHours(-24)

Get-WinEvent -FilterHashtable @{
    LogName   = @('System','Application')
    Level     = 1,2
    StartTime = $Depuis
} -ErrorAction SilentlyContinue |
    Select-Object TimeCreated, LogName, Id, ProviderName, LevelDisplayName, Message |
    Sort-Object TimeCreated -Descending |
    Format-List

When should you use it?

Run this after a crash, unexpected restart, or application failure.

What the script does

  • Levels 1 and 2 correspond to critical events and errors.
  • Change AddHours(-24) to adjust the time window.

Precautions

  • Event logs may contain errors with no real impact; always correlate the timestamp with the reported symptom.

Rollback

Read-only operation; no rollback is required.

♡ 0