Page 1 of 1

Wie sammle ich Netzwerkstatistiken mit PowerShell oder Klasse von Remote Machine in C#?

Posted: 14 Feb 2025, 14:14
by Anonymous
Ich versuche einen Ansatz zu erforschen und zu finden, der mir eine Ausgabe liefert, die die Netzwerkstatistik pro jeder Verbindung untersucht. Ich weiß, dass PowerShell die Gesamtstatistik des Netzwerks wie < /p>
bereitstellt

Code: Select all

(using WSMan)
pipeline.AddCommand("Get-NetTCPConnection");
pipeline.AddCommand("Select-Object").AddArgument("LocalAddress, LocalPort, RemoteAddress, RemotePort, State, OwningProcess");

pipeline.AddCommand("Get-NetAdapterStatistics");
pipeline.AddCommand("Select-Object").AddArgument("InterfaceAlias, OutgoingBytes, IncomingBytes");
< /code>
LocalAddress  LocalPort  RemoteAddress  RemotePort  State       OwningProcess
-----------------------------------------------------------------------------------------------------
192.168.1.10  49242      93.184.216.34  80         ESTABLISHED  1234
192.168.1.10  49243      93.184.216.34  443        ESTABLISHED  1235

InterfaceAlias  OutgoingBytes  IncomingBytes
-------------------------------------------------
Ethernet        1000000         2000000
Wi-Fi           500000          1500000
< /code>
Is there a class that I can use that will provide this information?
What I am expecting the output would be similar to the one below
--------------------------------------------------------
Local Address: 192.168.1.10
Local Port: 443
Remote Address: 203.0.113.5
Remote Port: 12345
State: Established
Bytes Sent: 1048576
Bytes Received: 2048000
Packets Sent: 512
Packets Received: 768
Owning Process ID: 1234
--------------------------------------------------------