这是我的工作,时间生成字段不会出现。
param ($redflags)
$count = 0
$n = get-eventlog $redflags -entrytype error, warning| where-object { $_.EntryType -eq 'Error' -or $_.EntryType -eq 'warning' }
$f = $n | foreach {$count++} | format-table @{Label="TimeGenerated"; Expression={$_.Timegenerated}} -autosize
$n
Write-host "The number of redflags is $count"
答案 0 :(得分:0)
如@PetSerAl所示,您没有向Format-Table
输送任何内容。我会将程序更改为以下内容:
param ($redflags)
$count = 0
$n = get-eventlog $redflags -entrytype error, warning
$n | format-table @{Label="TimeGenerated"; Expression={$_.Timegenerated}} -autosize
$n | foreach { $count++ }
$n
Write-Host "The number of redflags is $count"
-EntryType
已捕获所有错误和警告。