hyytaojunming 发表于 2018-9-2 12:13:42

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
  "

页: [1]
查看完整版本: powershell 检索日志信息