powershell - 在 PowerShell 中解析 Windows Defender 事件日志
问题描述
我需要解析 Windows Defender 事件日志。用这个命令
Get-WinEvent -LogName "Microsoft-Windows-Windows Defender/Operational" | Where-Object { $_.LevelDisplayName -ne "Information" } | Select-Object -ExpandProperty Message
我得到这个输出:
Windows Defender Antivirus has detected malware or other potentially unwanted software.
For more information please see the following:
https://go.microsoft.com/fwlink/?linkid=37020&name=Trojan:Win32/TFTPD32&threatid=12892&enterprise=0
Name: Trojan:Win32/TFTPD32
ID: 12892
Severity: Severe
Category: Trojan
Path: file:_\\server\share\path\file1.exe::$DATA; file:_\\server\share\path\file2.exe::$DATA; file:_\\server\share\path\file3.exe::$DATA;
Detection Origin: Network share
Detection Type: Concrete
Detection Source: Real-Time Protection
User: DOMAIN\user
Process Name: C:\Windows\SMSProxy\Microsoft.StorageMigration.Proxy.Service.exe
Signature Version: AV: 1.335.1263.0, AS: 1.335.1263.0, NIS: 1.335.1263.0
Engine Version: AM: 1.1.18000.5, NIS: 1.1.18000.5
当有多个文件并且以 Path: 开头的行很长时,它会被截断。不是消息属性,而只是行。当我使用事件日志查看器查看记录时,该行已完成。有没有办法获得全长的线路?
我只需要从 Message 属性(多行字符串)中获取带有 Name: 和 Path: 的行。如何使用例如 RegEx 获得它^\s+(Name|Path):
?
更新:
我不匹配事件日志记录,即使在事件日志中路径行被截断。
问题的第二部分仍然存在:如何从多行属性中只获取一些行?
解决方案
推荐阅读
- java - 为什么该方法也必须在 Parent 中,如果最后它会打印 Child 的内容
- docker - 如何将文件从本地复制到无根 podman 容器中
- python - 将 NestedStackedInline 写入模板
- apache-spark-sql - spark在查询中读取json字符串
- sql - 如何防止使用 not like 运算符过滤 SQL 中的相似词(意外结果)?
- python - 如何用循环制作计算器,直到我选择中断
- python - pandas 中的聚合和计数
- database-design - 足球/足球数据库设计
- php - Laravel 8 测试方法 Illuminate\Http\JsonResponse::getSession 不存在
- javascript - 在javascript中过滤对象