【问题标题】:WEVTUtil export certain eventWEVTUtil 导出特定事件
【发布时间】:2017-02-02 23:38:41
【问题描述】:

我只想从安全中导出事件 id 4624

下面的代码从安全中导出所有事件(我只想要 4624);

WEVTUtil query-events Security /rd:true /format:text > %~dp0Logins.txt /q:"<EventID>4624</EventID>"

当导出所有 4624 个事件时,我只想过滤事件:

<Data Name='LogonProcessName'>User32 </Data>

这将是带有 IP 的 RDP 日志,因为“Microsoft-Windows-TerminalServices-RemoteConnectionManager/Operational”中的日志没有 IP(只有用户名):(我听说这是因为 RDP 连接受 TLS 保护...

【问题讨论】:

    标签: windows batch-file event-viewer wevtutil


    【解决方案1】:

    我只想从安全中导出 Event ID 4624

    WEVTUtil query-events Security /rd:true /format:text > "%~dp0Logins.txt"<EventID>4624</EventID>"
    

    您对/q 选项使用了错误的格式。

    使用以下命令行:

    wevtutil qe Security "/q:*[System [(EventID=4648)]]" /rd:true /f:text > "%~dp0Logins.txt"
    

    如何将过滤器限制为包含User32Event ID 4624

    当导出所有 4624 个事件时,我只想过滤事件:

    <Data Name='LogonProcessName'>User32 </Data>
    

    使用以下命令行:

    wevtutil qe Security "/q:*[System [(EventID=4648)]]" /rd:true | findstr User32 >nul && wevtutil qe Security "/q:*[System [(EventID=4648)]]" /f:text /rd:true > "%~dp0Logins.txt"
    

    代码基于以下源链接。

    来源How to use wevtutil command to get event details if it only comply with specific text or word


    进一步阅读

    【讨论】:

    • 谢谢,过滤器效果很好!您能否解决名称中包含空格的文件夹的 %~dp0Logins.txt 问题?
    • 似乎只有第一个示例有效,但过滤不是:/
    • @acidmagic 您正在运行的确切命令行是什么?有错误吗?如果你只是输出到一个名为Logins.txt的文件,它是否有效?
    • wevtutil qe Security "/q:*[System [(EventID=4624)]]" /rd:true /c:1| findstr User32 &gt;nul &amp;&amp; wevtutil qe Security "/q:*[System [(EventID=4624)]]" /f:text /rd:true /c:1 &gt; "%~dp0logs.txt" 并且没有得到任何输出 (logs.txt) User32 存在于事件 4624 中
    • 请尝试删除两个出现的/c:1 答案已更新
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-18
    • 2015-12-08
    • 1970-01-01
    相关资源
    最近更新 更多