Powershell - Tail Windows Event Log? Is it possible?

Kit Ho picture Kit Ho · Mar 7, 2013 · Viewed 8.4k times · Source

How can i use powershell to tail a specific windows event log? Is it possible?

Answer

mjolinor picture mjolinor · Mar 7, 2013

I've done this on occasion:

$idx = (get-eventlog -LogName System -Newest 1).Index

while ($true)
{
  start-sleep -Seconds 1
  $idx2  = (Get-EventLog -LogName System -newest 1).index
  get-eventlog -logname system -newest ($idx2 - $idx) |  sort index
  $idx = $idx2
  }