Get Network Utilization by halr9000 28 months ago
View followups from Jason Ochoa | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1349"></script>download | new post
replace $inst with your NIC name. You can find that out by running (new-object System.Diagnostics.PerformanceCounterCategory(“network interface”)).GetInstanceNames()
- $cnt = 'Bytes Total/sec'
- $inst = 'Broadcom NetXtreme Gigabit Ethernet - Packet Scheduler Miniport'
- $cat = 'Network Interface'
- $cnt2 = 'Current Bandwidth'
- $cur = New-Object system.Diagnostics.PerformanceCounter($cat,$cnt,$inst)
- $max = New-Object system.Diagnostics.PerformanceCounter($cat,$cnt2,$inst)
- $curnum = $cur.NextValue()
- $maxnum = $max.NextValue()
- $util = (( $curnum * 8 ) / $maxnum ) * 100
- $util
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
PowerShell Code Repository