PowerShell Genie

PowerShell Event logs

Get-WinEvent reads the Windows event logs, including the modern per-application channels. Get-EventLog is the older cmdlet, limited to the classic logs, and it was removed in PowerShell 7. Use Get-WinEvent.

Lesson 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Overview

Filtering is the whole skill. Get-WinEvent -LogName System | Where-Object Id -eq 7001 reads the entire log into PowerShell and then discards almost all of it, which on a busy server takes minutes. -FilterHashtable pushes the filter into the log service, so only matching records are ever returned:

Get-WinEvent -FilterHashtable @{ LogName='System';Id=7001;StartTime=(Get-Date).AddDays(-1) }

The keys you will use are LogName, ProviderName, Id, Level, StartTime and EndTime. The speed difference is not marginal; it is the difference between a usable query and one you cancel.

Message text is expensive to render and locale-dependent, so filter on Id and ProviderName rather than searching Message. -MaxEvents caps the result, and it applies after filtering, so combine it with -FilterHashtable rather than using it alone.

Remote logs work with -ComputerName, and require the Remote Event Log Management firewall rule rather than WinRM.

Inspect this example’s structure

Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

Get-WinEvent -LogName System -MaxEvents 5 | Select-Object TimeCreated, Id, LevelDisplayName, ProviderName
  1. Stage 1Get-WinEvent-LogName -MaxEvents
  2. Stage 2Select-ObjectPositional values or no named parameters

    What happens

    This reads five records from the System log. -MaxEvents keeps it fast here, but on a real investigation you would add -FilterHashtable so the log service does the filtering. LevelDisplayName gives you the readable severity, where the raw Level property is a number.

    Worth remembering

    • Get-WinEvent replaces Get-EventLog, which is gone in PowerShell 7.
    • -FilterHashtable filters in the log service. Where-Object does not.
    • Filter on Id and ProviderName, not on Message text.
    • Remote reads need the Remote Event Log Management rule.

    Primary documentation

    Select-Object reference · Get-WinEvent reference

    Try it

    Illustrative output · values vary by environment

    1PS> Get-WinEvent -LogName System -MaxEvents 5 |
    2PS> Select-Object TimeCreated, Id, LevelDisplayName, ProviderName

    Example reader

    Inspect this page's example

    Fictional browser data when supported

    Run supported commands against the practice data, or inspect the example without executing it.

    Ready to inspect.

      Reads five System log records with the readable severity name.

      Show reference output

      Illustrative output · values vary by environment

      TimeCreated           Id    LevelDisplayName  ProviderName
      -----------           --    ----------------  ------------
      02/10/2026 10:51:12    7031  Error             Service Control Manager
      02/10/2026 10:32:05    7036  Information       Service Control Manager
      02/10/2026 09:18:20    6005  Information       EventLog
      02/10/2026 09:12:10    6006  Information       EventLog
      02/10/2026 08:45:02    7036  Information       Service Control Manager

      Practise this

      Filter error events

      Return complete System-log event records with LevelDisplayName Error.

      Review the lesson

      Keep going

      Next: PowerShell Windows networking
      Genie guidePowerShell Event logs

      Get-WinEvent reads the Windows event logs, including the modern per-application channels. Get-EventLog is the older cmdlet, limited to the classic logs, and it was removed in PowerShell 7. Use Get-WinEvent.