Lets look into logs!

Sometimes when you troubleshoot a machine, what’s the first thing you do? Look into the Windows logs right?, And yes it can be a mess, filtering out whats good info, and what’s bad info.
So a friend of mine worked on this scripts, and it too good to not share it.

This script will look into all logbooks then showing last 25 logs in the last 25 minutes, and out-grid all thing, then we can filter it how we want 🙂

Here is the script below:

Listing last 25 logs in all logbooks 25 minutes back

Created: 2018-09-24
Version: 1.0

Author : Pontus Wendt
Twitter: @pontuswendt
Blog : https://pontuswendt.blog

Disclaimer: This script is provided "AS IS" with no warranties, confers no rights and
is not supported by the author.

$computername = $env:COMPUTERNAME
$logs = Get-WinEvent -computername $computername -listlog *
$logs = $logs | where {$_.recordCount -gt 0}
$events = @()
foreach ($log in $logs)
Try {
[array]$events+= Get-WinEvent -ComputerName $computername -FilterHashtable @{Logname=$($log.logname)} | select -first 25 | where {$_.Timecreated -gt (get-date).AddMinutes(-25)} | select *,@{name="Eventlogname";Expression={$($log.logname)}}

$events | Out-GridView

Best part is, you can run it remotely if you want to. Just change the $computername variable.

After you run it, you can start filtering the “errors” if you want to. Just type in Error in the top field.

Good luck troubleshooting!

/Cheers Pontus





Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s