It seems the class to do this is MSFT_NetTransportConnection.
However I cannot query this class via Get-WmiObject:
C:\Users\Justin Dearing> Get-WmiObject MSFT_NetTransportConnection
Get-WmiObject : Invalid class "MSFT_NetTransportConnection"
At line:1 char:1
+ Get-WmiObject MSFT_NetTransportConnection
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
C:\Users\Justin Dearing> Get-WmiObject MSFT_NetTransportConnection -Namespace "root/StandardCimv2"
Get-WmiObject : Not supported
At line:1 char:1
+ Get-WmiObject MSFT_NetTransportConnection -Namespace "root/StandardC ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
C:\Users\Justin Dearing> Get-WmiObject MSFT_NetTransportConnection -Namespace "fff"
Get-WmiObject : Invalid namespace "fff"
At line:1 char:1
+ Get-WmiObject MSFT_NetTransportConnection -Namespace "fff"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
What am I doing wrong?
Can the MSFT_NetTcpConnection class be suitable?
Get-WmiObject -Namespace 'ROOT/StandardCimv2' -ClassName MSFT_NetTCPConnection |
Group-Object OwningProcess
You can also use Sort-Object to sort the list of processes with the most connections. This makes it easier to visually discover which processes have the most connections.
Get-CimInstance -Namespace root/standardcimv2 -ClassName MSFT_NetTCPConnection |
Group-Object -Property OwningProcess |
Sort-Object -Property Count
I also don't have that WMI/CIM class. You may need to figure out what namespace it is in to use it.
You can get the number of network connections that each process has by using Get-NetTCPConnection and grouping on the OwningProcess property.
Get-NetTCPConnection -State Established, TimeWait -ErrorAction SilentlyContinue |
Group-Object OwningProcess
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With