我需要解析 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: 的行。
我怎样才能得到它,例如正则表达式^\s+(Name|Path):
?
更新:
我不匹配的事件日志记录,即使在事件日志中,行路径被截断。
问题的第二部分仍然是:如何从多行属性中只获取一些行?