简单的问题,我有以下内容读取应用程序日志:
$out = @()
$endtime=[datetime]::Today
$starttime= $endtime.AddDays(-10)
$evts = get-winevent -FilterHashtable @{ logname="application"; Level= "1","2"; starttime= $starttime;endtime= $endtime } -maxevents 10 | select TimeCreated, Providername, id,Message
foreach( $evt in $evts){
$mess = RemoveBlankSpaces( $evt.Message)
$out += " $( $evt.ID), $( $evt.Providername), $( $evt.TimeCreated), $mess"
}
$out | out-file -filepath .\warning.txt
如何从evtx文件(已保存的事件日志文件)中读取它?
TIA!
答案 0 :(得分:0)
Get-WinEvent -Path C:\SavedAppLog.evtx
答案 1 :(得分:0)
添加请求的路径,如下所示:
$evts = get-winevent -FilterHashtable @{path="c:\mylogpath" logname="application"; Level= "1","2"; starttime = $starttime; endtime = $endtime } -maxevents 10 | select TimeCreated, Providername, id, Message
顺便说一句,我正在寻找一种将某些事件导出到摘要日志文件的方法。你的脚本帮助我这样做,谢谢! :)