PowerTip: View Network Statistics with PowerShell

Summary: Learn how to use Windows PowerShell to view network statistics.

Hey, Scripting Guy! Question How can I use Windows PowerShell to view the amount of data going through my network cards?

Hey, Scripting Guy! Answer One way is to use the performance counters.

To find available counters:

Get-Counter -ListSet ‘Network Adapter’ | select -ExpandProperty PathsWithInstances | sort

To view the statistics for a particular card:

 $test = Get-Counter -Counter “Network Adapter(Qualcomm Atheros AR5007 802.11b_g WiFi Adapter)Bytes Total/sec” -MaxSamples 30

(This records thirty seconds of data by using the default sampling interval.)

To get the total traffic, use Measure-Object:

$test.CounterSamples | measure cookedvalue –Sum

(The –Sum property of the output holds the traffic level.)