1

我一直在到处寻找,只是想弄清楚这个“级别”是什么意思运行 Get-WinEvent。

例如,

Get-WinEvent –FilterHashtable @{logname=’application’; level=2; starttime=$time; id=20}

这里代表什么level=2?我问的原因是我正在尝试验证每个日志的严重性,并且它是否level=2代表与严重性相关的任何内容。

4

2 回答 2

5

让我们尝试找出:

#Get sample object
$t = Get-WinEvent -MaxEvents 1 -FilterHashtable @{ Logname='application'; level=2 }

#Explore properties and type
$t.GetType().Fullname
System.Diagnostics.Eventing.Reader.EventLogRecord

对EventLogRecord的快速 msdn 搜索将我们指向EventLogRecord.Level 属性

获取事件的级别。级别表示事件的严重性。对于关卡的名称,获取 LevelDisplayName 属性的值

#Check out Level vs LevelDisplayName
$t | Format-Table -Property Level, LevelDisplayName -AutoSize

Level LevelDisplayName
----- ----------------
    2 Error 

在我的日志中快速搜索以列出一些级别值:

Get-WinEvent @{ logname='application' } | Select-Object Level, LevelDisplayName -Unique | Sort-Object Level

Level LevelDisplayName
----- ----------------
    0 Information     
    2 Error           
    3 Warning         
    4 Information     

它还在 Level-property 页面上说它使用StandardEventLevel枚举,所以让我们列出它的值:

[enum]::GetValues([System.Diagnostics.Eventing.Reader.StandardEventLevel]) | Select-Object {$_}, {$_.value__ }

           $_ $_.value__ 
           -- -----------
    LogAlways           0
     Critical           1
        Error           2
      Warning           3
Informational           4
      Verbose           5
于 2016-02-16T21:05:55.277 回答
0

有关更多信息,请参阅此链接。MSDN

实际上,您正在寻找一个 winmeta.xml 文件,但它会包含这些基本值:

  • 日志始终:0,
  • 关键:1,
  • 错误:2,
  • 警告:3,
  • 资料:4,
  • 详细:5,
  • 其余16以下保留
于 2016-02-16T21:08:17.440 回答