$targetTs = "2026-05-20 02:20:00" # Use hex escape or similar if possible, or just standard string. # Actually, PowerShell strings are Unicode. $kws = @( 'print-retry-compensation', 'print_retry_compensation\.js', 'retryFailed', '触发补打', '任务执行完成', 'SCHEDULE', '/__schedule\?path=D:\\wms\\app\\schedule\\print_retry_compensation\.js' ) $stats = [ordered]@{} foreach($k in $kws) { $stats[$k] = 0 } Get-ChildItem logs/wms/wms-web.log* | ForEach-Object { $fs = New-Object System.IO.FileStream($_.FullName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::ReadWrite) # The logs seem to be UTF-8 $reader = New-Object System.IO.StreamReader($fs, [System.Text.Encoding]::UTF8) while($null -ne ($line = $reader.ReadLine())){ if($line -match '^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})'){ $ts = $matches[1] if($ts -ge $targetTs){ foreach($k in $kws){ if($line -match $k){ $stats[$k]++ } } } } } $reader.Close() $fs.Dispose() } $stats.Keys | ForEach-Object { "$_: $($stats[$_])" }