powershell 檢索日誌信息

$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

"


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章