This might help you,

The below alias will connect, via coms to a com object, and perform a 'netstats -a' which will output into a file, oports.txt, which will be in your mIRCdir if you need it, following that, a /filter will be performed to throw all the data (required), into a hash table, so you can use it via there, if you like.

alias getports {
var %f = $+(",$mircdir,oports.txt,")
if ($isfile(%f)) { .remove %f }
if ($hget(oports)) { .hfree oports }
.comopen oPorts WScript.Shell
.comclose oPorts $com(oPorts, Run, 1, bstr, $+(%,COMSPEC%) /c netstat.exe -a > %f, uint, 0, bool, true)
filter -fk %f gp.filter *:*
}

alias gp.filter { hadd -sm oports $+(conn.,$calc($hget(oports,0).item + 1)) $1- }

Just, /getports - then perhaps open oports.txt or view your hash table, to remove the echo of the /hadd simply remove the -sm

Eamonn.