I am trying to get all local ports that are in listening state. Using
netstat -a -n
I get the following output:
Proto Local Address Foreign Address State
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING //for example, demo data is given
But I only wan't to get the port numbers.
1111 //for ex, this is in listening state.
In Windows 10, I can use
Get-NetTCPConnection -State Listen | group localport -NoElement
Which works but this command isn't available on Windows 7
Not sure whether there is a Windows 7 cmdlet available but you could parse the netstat result:
Then you can retrieve the ports using something like this: