Created
March 24, 2012 07:47
-
-
Save kiyokura/2179802 to your computer and use it in GitHub Desktop.
ヒーロー島 PowerShell ハンズオン 問題2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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