Problem
You want to retrieve the most recent entries from an event log.
Solution
To retrieve the most recent entries from an event log, use the –Newest parameter of the GetEventLog cmdlet, as shown in Example 201.
Example 201. Retrieving the 10 newest entries from the System event log
PS >GetEventLog System Newest 10 | FormatTable Index,Source,Message A
Index Source Message
2922 Service Control Manager The Background Intelligent Transfer Servi... 2921 Service Control Manager The Background Intelligent Transfer Servi... 2920 Service Control Manager The Logical Disk Manager Administrative S... 2919 Service Control Manager The Logical Disk Manager Administrative S... 2918 Service Control Manager The Logical Disk Manager Administrative S...
2917 TermServDevices
Driver Microsoft XPS Document Writer requ...
2916 Print
Printer Microsoft Office Document Image W...
2915 Print
Printer Microsoft Office Document Image W...
2914 Print
Printer Microsoft Office Document Image W...
2913 TermServDevices
Driver Microsoft Shared Fax Driver requir...
Discussion
The –Newest parameter of the GetEventLog cmdlet retrieves the most recent entries from an event log that you specify.
For more information about the GetEventLog cmdlet, type GetHelp GetEventLog.