Finding Errors since Yesterday

by Mar 12, 2014

Relative dates are important to get data within a special time frame, avoiding hard-coded dates and times.

This script will get all error and warning events from the System log since yesterday (24 hours ago):

$today = Get-Date
$1day = New-TimeSpan -Days 1

$yesterday = $today - $1day


Get-EventLog -LogName system -EntryType Error, Warning -After $yesterday 

Twitter This Tip! ReTweet this Tip!