$strlog="c:\log\applog.txt";$e=$i=$w=0
$tpath=Test-Path $strlog
if(!$tpath)
{
New-Item -Path "c:\log" -ItemType dir
New-Item -Path $strlog -ItemType file
}
Get-EventLog -LogName Application | Out-File $strlog
switch -Wildcard -File $strlog {
"*error*" {$e++}
"*info*"{$i++}
"*warn*"{$w++}
}
Write-Output "
$strlog contains the following:
errors $e
informations $i
warnings $w
"
本文出自 “加速器” 博客,请务必保留此出处http://3544640.blog.51cto.com/3534640/1643686
原文地址:http://3544640.blog.51cto.com/3534640/1643686