Powershell - Tail Windows Event Log? Is it possible?

前端 未结 3 645
你的背包
你的背包 2021-02-05 11:56

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

3条回答
  •  -上瘾入骨i
    2021-02-05 12:26

    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
      }
    

提交回复
热议问题