Skip to content

Instantly share code, notes, and snippets.

@4x0v7
Created June 4, 2022 04:53
Show Gist options
  • Save 4x0v7/771bfca1e387551040fcb8f9b097c709 to your computer and use it in GitHub Desktop.
Save 4x0v7/771bfca1e387551040fcb8f9b097c709 to your computer and use it in GitHub Desktop.
Get Process listening on Port 6443
Get-Process -Id $(Get-NetTCPConnection -State Listen | Sort-Object -Property LocalPort | Where-Object {$_.LocalPort -eq 6443} | Select-Object -ExpandProperty OwningProcess)
$ListenPort = 6443
Get-Process -Id $(Get-NetTCPConnection -State Listen | Sort-Object -Property LocalPort | Where-Object {$_.LocalPort -eq $ListenPort} | Select-Object -ExpandProperty OwningProcess)
Get-Process -Id $(Get-NetTCPConnection -State Listen | Sort-Object -Property LocalPort | Where-Object {$_.LocalPort -eq $ListenPort} | Select-Object -ExpandProperty OwningProcess) | Select-Object -ExpandProperty ProcessName
@4x0v7
Copy link
Author

4x0v7 commented Jun 4, 2022

Get the name of the process that is listening on a Port.

K8s kube-apiserver listens on port 6443 by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment