List Open UDP Ports Using Powershell

In the last post I showed how to list open TCP ports using Powershell. Unlike the netstat command in DOS, Powershell splits TCP and UDP into two different commands, Get-NetTCPConnection and Get-NetUDPEndpoint. Here are some examples of Get-NetUDPEndpoint.

Get-NetUDPEndpoint by itself will return the local address and local port

Get-NetUDPEndpoint

To show listening ports filter for the address 0.0.0.0

Get-NetUDPEndpoint | Where {$_.LocalAddress -eq "0.0.0.0"}

To view the owning process ID, add the OwningProcess field.

Get-NetUDPEndpoint | Where {$_.LocalAddress -eq "0.0.0.0"} | select LocalAddress,LocalPort,OwningProcess

And use this command to display the name of the owning process.

Get-NetUDPEndpoint | Where {$_.LocalAddress -eq "0.0.0.0"} | select LocalAddress,LocalPort,@{Name="Process";Expression={(Get-Process -Id $_.OwningProcess).ProcessName}}

In my next post I will demonstrate combining Get-NetTCPConnection and Get-NetUDPEndpoint into a single command.

Leave a Reply

Your email address will not be published. Required fields are marked *