Solución

Solución

Usando netstat -a -o -n puedo obtener la lista de puertos y PID.

luego necesito ir al administrador de tareas, agregar el PID y ver quién es. (bastante frustrante)

ingrese la descripción de la imagen aquí

Me preguntaba si hay un comando CMD que lo haga todo ( usando find,, for)powershell

para poder obtener el nombre del proceso

Respuesta1

Solución

Utilice el -bparámetro:

  -b            Displays the executable involved in creating each connection or
                listening port. In some cases well-known executables host
                multiple independent components, and in these cases the
                sequence of components involved in creating the connection
                or listening port is displayed. In this case the executable
                name is in [] at the bottom, on top is the component it called,
                and so forth until TCP/IP was reached. Note that this option
                can be time-consuming and will fail unless you have sufficient
                permissions.

NotaEl netstat -bcomando fallará a menos que se ejecute desde un símbolo del sistema elevado.

Solución alterna

Filtra la lista de procesos y encuentra el PID que te interesa:

tasklist | findstr /c:"PID"  


Solución alternativa

Puedes usar Tcpvcon.exeen su lugar. No se requieren derechos de administrador.

tcpvconEl uso es similar al de la utilidad integrada de Windows netstat.

Usage: tcpvcon [-a] [-c] [-n] [process name or PID]

 -a Show all endpoints (default is to show established TCP connections).
 -c Print output as CSV.
 -n Don't resolve addresses.

Respuesta2

creo que estas buscandoTCPVerde SysInternals.

Respuesta3

Aquí hay un ejemplo para Windows que usa FORpara analizar netstatla salida y luego DO tasklistcon /fiun filtro en pid para mostrar el nombre del proceso.

El último hallazgo es eliminar tasklistlos encabezados.

FOR /F "usebackq tokens=5 delims= " %i IN (`netstat -ano ^|find "443"`) DO @tasklist /fi "pid eq %i" | find "%i"

imprime registros de salida como

tomcat8.exe.x64               4240 Services                   0    931,864 K

Se pueden agregar campos adicionales netstatagregando tokens.

Respuesta4

Intenta usar esto...

Nombre del proceso con marca de tiempo :) en oneliner... no es necesario realizar secuencias de comandos de forma rápida y sencilla...

Puede cambiar el parámetro SYN_SENT mediante ESTABLECIDO o ESCUCHANDO

filter timestamp {"$(Get-Date -Format G): $_"};netstat -abno 1 | Select-String -Context 0,1 -Pattern LISTENING|timestamp

filter timestamp {"$(Get-Date -Format G): $_"};netstat -abno 1 | Select-String -Context 0,1 -Pattern SYN_SENT|timestamp

información relacionada