代码之家  ›  专栏  ›  技术社区  ›  soMuch2Learn

从应用程序日志中提取“故障进程id”

  •  1
  • soMuch2Learn  · 技术社区  · 8 年前

    Get-EventLog application 1000 -entrytype error -newest 5 | Select-Object  timegenerated,message,@{name='Executable';expression={$_.ReplacementStrings[0]}}
    
    1 回复  |  直到 8 年前
        1
  •  1
  •   user6811411 user6811411    8 年前

    这应该让您从RegEx(命名捕获组)开始

    $log = Get-EventLog application 1000 -entrytype error -newest 5 | 
      Select-Object  timegenerated,message,@{name='Executable';expression={$_.ReplacementStrings[0]}}
    $log | %{
      if ($_.message -match '(?smi)Faulting process id: (?<PID>0x[0-9a-f]+)'){
        $_.Executable,$matches.PID
      }
    }
    

    我会把它放在一张桌子/笔记本上,对我来说,今天已经很晚了。