# Read-only: every 500 ms, log Chrome's established TCP connections (remote address + port). # Stops when conn.stop appears next to this script. $dir = Split-Path -Parent $MyInvocation.MyCommand.Path $out = Join-Path $dir 'conns.csv' $stop = Join-Path $dir 'conn.stop' if (Test-Path $stop) { Remove-Item $stop } 'ts,remote,port' | Out-File $out -Encoding ascii while (-not (Test-Path $stop)) { $ids = (Get-Process chrome -ErrorAction SilentlyContinue).Id $ts = Get-Date -Format 'HH:mm:ss.f' if ($ids) { Get-NetTCPConnection -State Established -ErrorAction SilentlyContinue | Where-Object { $ids -contains $_.OwningProcess -and $_.RemotePort -eq 443 } | ForEach-Object { "{0},{1},{2}" -f $ts, $_.RemoteAddress, $_.LocalPort } | Out-File $out -Append -Encoding ascii } Start-Sleep -Milliseconds 500 }