Skip to content

Instantly share code, notes, and snippets.

@winkler-winsen
Last active September 28, 2023 10:19
Show Gist options
  • Save winkler-winsen/382b2198c1487096102eeb2411137bee to your computer and use it in GitHub Desktop.
Save winkler-winsen/382b2198c1487096102eeb2411137bee to your computer and use it in GitHub Desktop.
PowerShell netstat -anob replacement. Shows listening TCP and UDP ports and its process names
(Get-NetUDPEndpoint |
Select-Object @{L="Proto"; E={"UDP"}},
LocalAddress,
LocalPort,
OwningProcess,
@{L="Process"; E={((Get-Process -ID $_.OwningProcess).Name)}},
@{L="Path"; E={((Get-Process -ID $_.OwningProcess).Path)}}) +
(Get-NetTCPConnection -State Listen |
Select-Object @{L="Proto"; E={"TCP"}},
LocalAddress,
LocalPort,
OwningProcess,
@{L="Process"; E={((Get-Process -ID $_.OwningProcess).Name)}},
@{L="Path"; E={((Get-Process -ID $_.OwningProcess).Path)}}) |
Sort-Object Process, Proto, LocalPort, LocalAddress |
Format-Table -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment