Friday, May 31, 2024

Powershell Function to List Ports in Use by a Java Prog

Replace"YourCurrentProject" default with your most frequent query.

Add the following to your $profile (PS> code $profile).

function lsAppPorts($prog = "YourCurrentProject") {
    foreach($a in jps -l | C:\Progra~2\GnuWin32\bin\awk "/$prog/{ print `$1; }") {
        netstat -ano | findstr $a
    }
}

Note: Requires Gnu Awk for Windows

No comments:

Post a Comment