有log
一个这种类型的文件
02.11.2024 19:13:47.431 Connect socket [73664050] ("", "10.10.10.1")
02.11.2024 19:13:47.789 [159211164] TX
02.11.2024 19:13:47.789 [159211164] RX
02.11.2024 19:13:47.797 [159211164] TX
02.11.2024 19:13:47.797 [159211164] RX
02.11.2024 19:13:48.274 Socket [73664050] info: (...э.A ...эADDRESS=71F2;71F2§.)
02.11.2024 19:13:48.274 Socket [73664050] device codes 71F2 (29170)
02.11.2024 19:15:14.257 [73664050] TX
02.11.2024 19:15:14.257 [73664050] RX
02.11.2024 19:15:14.267 [73664050] TX
02.11.2024 19:15:14.267 [73664050] RX
.....
02.11.2024 19:20:14.907 [159211164] TX
02.11.2024 19:20:14.907 [159211164] RX
02.11.2024 19:20:14.921 [159211164] TX
02.11.2024 19:20:14.921 [159211164] RX
02.11.2024 19:20:20.142 [159211164] RX
02.11.2024 19:20:20.992 Disconnect socket [73664050] ("", "10.10.10.1")
02.11.2024 19:20:21.106 [159211164] RX
02.11.2024 19:20:21.127 [159211164] RX
02.11.2024 19:20:21.396 [159211164] TX
02.11.2024 19:20:21.396 [159211164] RX
02.11.2024 19:20:21.405 [159211164] TX
02.11.2024 19:20:21.405 [159211164] RX 06
02.11.2024 19:20:22.227 Connect socket [184509040] ("", "10.10.10.2")
02.11.2024 19:20:22.962 Socket [184509040] info: (...э.A ...эADDRESS=7192;7192.м)
02.11.2024 19:20:22.962 Socket [184509040] device codes 7192 (29074)
您需要获取ip
这种格式的设备地址和代码
Device_Code ip
71F2 (29170) 10.10.10.1
7192 (29074) 10.10.10.2
问题是连接可能包含与其他设备的断开连接。并且只能通过socket来区分。
UDP协议
我尝试创建正则表达式来采样数据 。
foreach($file in $filesed)
{
$arrayFromFile = Get-Content -Path $file -Encoding ansi
$arrayFromFile -split '\n' | Select-String -Pattern $patern |
ForEach-Object {
[PSCustomObject]@{
LineNanber = $_.LineNumber
Cocket = $_.Matches.Groups[1]
coments = $_.Matches.Groups[2]
text = $_.Matches.Groups[3]
}
}
}
但结论却不是我所期望的。我无法从搜索中排除信息