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

Ein Treffpunkt für C#-Programmierer
Anonymous
 Wie sammle ich Netzwerkstatistiken mit PowerShell oder Klasse von Remote Machine in C#?

Post 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
--------------------------------------------------------

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post