Get eventlog data. [DEPRECATED]. This cmdlet was removed from PowerShell in version 6.
Syntax
Get-EventLog [-logName] string [-newest int]
[CommonParameters]
Get-EventLog [-list] [-asString]
[CommonParameters]
Key:
-logName string
Name of the log file from which to get log events.
-list
Return a list of the log files available.
-asString
Send the output as a string, instead of object(s).
-newest
Gets the newest 'n' event log entries, where
'n' represents a numerical value for the newest
entries in the eventlog.
In PowerShell 7.0 Get-EventLog is no longer supported, use Get-WinEvent instead.
Get-EventLog works against the 'classic' event logs making it compatible with Windows XP and 2003. When used with current versions of Windows, this cmdlet will be very slow and will often return incorrect event messages.
To query the new style event logs first introduced in Windows Vista use Get-WinEvent.
Event logs often contain tens of thousands of event log entries, so consider using -Newest parameter to limit the number of entries returned.
Display the 50 most recent entries in the Application event log:
PS C:\> Get-EventLog -newest 50 -logname application
Get the 100 recent entries from the System event log and store in $MyEvents.
Then pipeline the results to group-object to group them by event id.
PS C:\> $events = Get-EventLog -logname system -newest 100
PS C:\> $events | Group-Object eventid
Write a new message to the Application eventlog:
PS C:\> $log = Get-EventLog -List | Where-Object { $_.Log -eq "Application" }
PS C:\> $log.Source = "Test"
PS C:\> $log.WriteEntry("Test message")
PS C:\> Get-EventLog Application -Newest 1 | Select-Object Message
“We are not going to be able to operate our spaceship earth successfully nor for much longer unless we see it as a whole spaceship and our fate as common.
It has to be everybody or nobody” ~ Buckminster Fuller
Get-WinEvent - Get event log data.
Get-Event - Get PowerShell events in the event queue.