Skip to content

Instantly share code, notes, and snippets.

@kiyokura
Created March 24, 2012 07:47
Show Gist options
  • Save kiyokura/2179802 to your computer and use it in GitHub Desktop.
Save kiyokura/2179802 to your computer and use it in GitHub Desktop.
ヒーロー島 PowerShell ハンズオン 問題2
$logs = Get-EventLog Application |
?{($_.TimeWritten -ge (get-date).AddDays(-1)) -and ($_.EntryType -eq "Error" -or $_.EntryType -eq "Warning" -or $_.EntryType -eq "Information")}
$err_count=0
$warn_count = 0
$info_count = 0
foreach($d in $logs){
if($d.EntryType -eq 'Error'){
$err_count++
$d
}elseif($d.EntryType -eq 'Warning'){
$warn_count++
$d
}elseif($d.EntryType -eq 'Information'){
$info_count++
}
}
"24時間以内にアプリケーションログでエラー:" + $err_count + "件、警告:" + $warn_count + "件、情報:" + $info_count + "件が記録されています。"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment