November 4th, 2013

PowerTip: View Network Statistics with PowerShell

Doctor Scripto
Scripter

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.) 

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.