• How about using this for a TSQL based solution?:

    SELECT DISTINCT(local_tcp_port) FROM sys.dm_exec_connections

    WHERE net_transport='TCP'