Загрузка данных


$path = "C:\Users\vbelopukhov\Downloads\resp.bin"

try {
    $bytes = [System.IO.File]::ReadAllBytes($path)
    Write-Host "OK, bytes read:" $bytes.Length -ForegroundColor Green
} catch {
    Write-Host "READ ERROR:" -ForegroundColor Red
    Write-Host $_.Exception.Message -ForegroundColor Red
    return
}

$text = [System.Text.Encoding]::Latin1.GetString($bytes)

$patterns = @("<%@", "Stack trace:", ".getFile")

foreach ($p in $patterns) {
    $idx = $text.IndexOf($p)
    if ($idx -ge 0) {
        Write-Host "FOUND:" $p "at offset" $idx -ForegroundColor Green
        $start = [Math]::Max(0, $idx - 100)
        $len = [Math]::Min(300, $text.Length - $start)
        Write-Host "--- context ---"
        Write-Host $text.Substring($start, $len)
        Write-Host "---------------"
    } else {
        Write-Host "NOT FOUND:" $p -ForegroundColor Yellow
    }
}