# Logs, once a second, Chrome's established TCP connections: IPv4 vs IPv6 counts and every remote address. # Reads the local connection table only; sends no traffic. Stops when stop.flag appears. $dir = $PSScriptRoot $out = Join-Path $dir 'chromefam.csv' if (-not (Test-Path $out)) { 'ts,v4,v6,remotes' | Out-File $out -Encoding ascii } while (-not (Test-Path (Join-Path $dir 'stop.flag'))) { $pids = (Get-Process chrome -ErrorAction SilentlyContinue).Id $v4 = 0; $v6 = 0; $rem = @{} if ($pids) { foreach ($c in Get-NetTCPConnection -State Established -ErrorAction SilentlyContinue) { if ($pids -notcontains $c.OwningProcess) { continue } $ra = $c.RemoteAddress if ($ra -like '::ffff:*' -or $ra -notmatch ':') { $v4++ } else { $v6++ } $rem[$ra] = 1 + [int]$rem[$ra] } } $list = ($rem.GetEnumerator() | Sort-Object Value -Descending | ForEach-Object { "$($_.Key)=$($_.Value)" }) -join ' ' '{0},{1},{2},{3}' -f (Get-Date -Format 'HH:mm:ss.fff'), $v4, $v6, $list | Out-File $out -Append -Encoding ascii Start-Sleep -Milliseconds 1000 }