Evaluating Event Log Data (Part 1)

by Jun 2, 2021

Event logs contain hugely useful information about almost any aspect of your Windows system. When using the deprecated Get-EventLog cmdlet, however, only a fraction of this information is accessible because this cmdlet can only access the older classic logs. That’s why the cmdlet was removed from PowerShell 7 altogether.

In PowerShell 3, a faster and more powerful replacement cmdlet was added: Get-WinEvent. This cmdlet can filter any log file, based on query items provided in a hash table.

For example, this one-liner dumps all events written by the Windows Update Client using the event ID 19, across all event log files:

Get-WinEvent -FilterHashTable @{
    ID=19
    ProviderName='Microsoft-Windows-WindowsUpdateClient'
} | Select-Object -Property TimeCreated, Message

The result is a list of installed updates:

 
TimeCreated         Message                                                                                            
-----------         -------                                                                                            
05.05.2021 18:13:34 Installation erfolgreich: Das folgende Update wurde installiert. Security Intelligence-Update für
                    Microsoft Defender Antivirus - KB2267602 (Version 1.337.679.0)            
05.05.2021 00:11:33 Installation erfolgreich: Das folgende Update wurde installiert. Security Intelligence-Update für
                    Microsoft Defender Antivirus - KB2267602 (Version 1.337.615.0)                 
04.05.2021 12:07:03 Installation erfolgreich: Das folgende Update wurde installiert. Security Intelligence-Update für
                    Microsoft Defender Antivirus - KB2267602 (Version 1.337.572.0)                                    
03.05.2021 23:54:58 Installation erfolgreich: Das folgende Update wurde installiert. Security Intelligence-Update für
                    Microsoft Defender Antivirus - KB2267602 (Version 1.337.528.0)  
... 
 


Twitter This Tip! ReTweet this Tip!