0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

WindowsイベントログのアプリケーションとSystemをサマリしたい

0
Last updated at Posted at 2025-07-18

最近のアプリケーションログとSystemログをサマリ表示します。

$param = @{
    LogName = "Application"              # アプリケーション
    Level = 1,2                          # 重大とエラー
    StartTime = (Get-Date).AddHours(-12) # 過去12時間
}

Get-WinEvent -FilterHashtable $param `
    | Select-Object  @{N="Level";E={$_.LevelDisplayName}},TimeCreated,ProviderName,Id,Message `
    | Format-Table -AutoSize
$param = @{
    LogName = "System"                   # システム
    Level = 1,2                          # 重大とエラー
    StartTime = (Get-Date).AddHours(-12) # 過去12時間
}

Get-WinEvent -FilterHashtable $param `
    | Select-Object  @{N="Level";E={$_.LevelDisplayName}},TimeCreated,ProviderName,Id,Message `
    | Format-Table -AutoSize

特定のログを除外する場合

# 除外フィルタの定義
filter Skip-Event {
    param($providerName, $id)
    if($_.providerName -eq $providerName -and $_.id -eq $id){
        return $null
    }
    else {
        return $_
    }
}

# レベル列の変換条件
$Level = @{
    Name="Level"
    Expression={ $_.LevelDisplayName }
}

# 日時列の変換条件
$TimeCreated = @{
    Name="TimeCreated"
    Expression={ $_.TimeCreated.ToString("MM/dd HH:mm:ss") }
}

# 検索条件
$param = @{
    LogName = "System"                   # システム
    Level = 1,2                          # 重大とエラー
    StartTime = (Get-Date).AddHours(-12) # 過去12時間
}

# 検索実行
Get-WinEvent -FilterHashtable $param `
    | Skip-Event Microsoft-Windows-WindowsUpdateClient 20 `
    | Skip-Event Microsoft-Windows-Bits-Client 16398 `
    | Select-Object $Level,$TimeCreated,ProviderName,Id,Message `
    | Format-Table -AutoSize

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?