Powershell-尾部Windows事件日志?是否有可能?

Powershell-尾部Windows事件日志?是否有可能?

问题描述:

如何使用Powershell跟踪特定的Windows事件日志? 有可能吗?

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

我有时会这样做:

$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
  }