# 取得應用程式事件檢視器中等級為錯誤的最近10筆事件
$events = Get-EventLog -LogName Application -EntryType Error -Newest 10
# 顯示事件資訊
foreach ($event in $events) {
Write-Host "事件時間: $($event.TimeGenerated)"
Write-Host "事件ID: $($event.EventID)"
Write-Host "消息: $($event.Message)"
Write-Host "----------------------"
}
------------------------------------------------------------------------------------------------
Get-WinEvent -FilterHashtable @{
"LogName" = "Application"
"Level" = 2 # 2 代表錯誤,可以根據需要調整
} | Select-Object * -First 10
沒有留言:
張貼留言