Get-EventLog in PowerShell
Get-EventLog in PowerShell
The Get-EventLog cmdlet in PowerShell can help you view events as you would in Event Viewer, but within your PowerShell Terminal.
In this post I’ll share a few examples of use:
# Get List of Event Logs Available
# Show Events by Count
# Show Events by Message Name
# Show Full Message of an Event
Get List of Event Logs Available
#Get List of Event Logs Available Get-EventLog -List
![](https://peter-whyte.com/wp-content/uploads/2021/10/get-eventlog_list.png)
Show Events by Count
# Show Events by Count Get-EventLog -LogName Application | Group-Object -Property Source -NoElement | Sort-Object -Property Count -Descending
![](https://peter-whyte.com/wp-content/uploads/2021/10/get-eventlog_application_counts.png)
Show Events by Message Name
# Show Events by Message Name Get-EventLog -LogName Application -Newest 10 -Message *MSSQLSERVER*
![](https://peter-whyte.com/wp-content/uploads/2021/10/get-eventlog_application_mssqlserver.png)
Show Full Message of an Event
# Show Full Message of an Event Get-EventLog -LogName Application -Newest 1 -Message *MSSQLSERVER* | Select Message
![](https://peter-whyte.com/wp-content/uploads/2021/10/get-eventlog_application_mssqlserver_select_message.png)
0 Comments