This PowerShell code retrieves and processes Windows event log entries...

August 22, 2025 at 07:39 PM

Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4624} | Select-Object TimeCreated, Id, @{Name='DetailedMessage'; Expression={$_.Message}}

This PowerShell code retrieves and processes Windows event log entries from the Security log with a specific event ID. Here's a detailed breakdown of what it does:

  1. Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4624}:

    • This retrieves event log entries from the Security log in Windows Event Viewer where the event ID is 4624.
    • Event ID 4624 corresponds to a successful logon event in Windows systems (audit success for user logins).
  2. | (Pipeline):

    • The results from Get-WinEvent are passed (via the pipeline) to the next command, Select-Object.
  3. Select-Object TimeCreated, Id, @{Name='DetailedMessage'; Expression={$_.Message}}:

    • Select-Object is used to select specific properties of the retrieved event logs and rename/add custom properties:
      • TimeCreated: Date and time when the event was logged.
      • Id: The ID of the event (4624 in this case).
      • @{Name='DetailedMessage'; Expression={$_.Message}}: Creates a custom property named DetailedMessage that extracts the detailed event log message from the Message property of the event objects.

Output:

The code outputs a list of objects with three columns:

  • TimeCreated: When the event occurred.
  • Id: Event ID (4624).
  • DetailedMessage: The full text of the message for each corresponding event.

This is typically used for auditing user logon activity on a system by inspecting these specific security logs.

Generate your own explanations
Download our vscode extension
Read other generated explanations

Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node