I am trying to get a count of connections from a remote server.
For some reason I don't get a return value at all when I have a single connection.
0 connections works fine as well as anything more that 1 but a single connection will not return a count.
When I try to get a count of connections to my remote computer here is what happens:
Without Count and a single connection:
PS C:\Users\jmergens\Desktop\Auto-Scale> Invoke-Command -ComputerName CPN1 -ScriptBlock {(get-nettcpconnection -state established -localport 443 -ErrorAction silentlycontinue)}
LocalAddress LocalPort RemoteAddress RemotePort State AppliedSetting OwningProcess PSComputerName
------------
--------- ------------- ---------- ----- -------------- ------------- --------------
172. 18.21.134 443 172.18.12.141 51082 5 1 4 CPN1
With Count and a single connection:
PS C:\Users\jmergens\Desktop\Auto-Scale> Invoke-Command -ComputerName CPN1 -ScriptBlock {(get-nettcpconnection -state established -localport 443 -ErrorAction silentlycontinue).count}
With Count and 4 connections:
PS C:\Users\jmergens\Desktop\Auto-Scale> Invoke-Command -ComputerName CPN1 -ScriptBlock {(get-nettcpconnection -state established -localport 443 -ErrorAction silentlycontinue).count}
4
Without Count and 4 connections:
PS C:\Users\jmergens\Desktop\Auto-Scale> Invoke-Command -ComputerName CPN1 -ScriptBlock {(get-nettcpconnection -state established -localport 443 -ErrorAction silentlycontinue)}
LocalAddress LocalPort RemoteAddress RemotePort State AppliedSetting OwningProcess PSComputerName
------------
--------- ------------- ---------- ----- -------------- ------------- --------------
172. 18.21.134 443 172.18.12.141 51082 5 1 4 CPN1
172. 18.21.134 443 172.18.21.134 50308 5 1 4 CPN1
172. 18.21.134 443 172.18.12.141 51181 5 1 4 CPN1
172. 18.21.134 443 172.18.21.134 50313 5 1 4 CPN1
Can anyone help me with this?
I tried this on 5.1 and 7.3