PoshCode Archive  Artifact [975f82f76e]

Artifact 975f82f76e0f853cc93e9f8208ad2d4f0b0722024d8636d6dd8ead7085caa135:

  • File Get-Network-Utilization.ps1 — part of check-in [fdbcf99ada] at 2018-06-10 12:56:55 on branch trunk — replace $inst with your NIC name. You can find that out by running (new-object System.Diagnostics.PerformanceCounterCategory(“network interface”)).GetInstanceNames() (user: halr9000 size: 824)

# encoding: ascii
# api: powershell
# title: Get Network Utilization
# description: replace $inst with your NIC name. You can find that out by running (new-object System.Diagnostics.PerformanceCounterCategory(“network interface”)).GetInstanceNames()
# version: 0.1
# author: halr9000
# license: CC0
# x-poshcode-id: 1349
# x-archived: 2016-10-24T04:58:46
# x-published: 2009-09-29T11:36:00
#
#
$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