# encoding: ascii
# api: powershell
# title: Get Network Utilization
# description: get utilization from all network interfaces
# version: 0.1
# author: halr9000
# license: CC0
# x-poshcode-id: 1352
# x-derived-from-id: 1900
# x-archived: 2016-10-20T07:00:22
# x-published: 2009-09-29T17:16:00
#
#
$cnt = 'Bytes Total/sec'
$cat = 'Network Interface'
$cnt2 = 'Current Bandwidth'
foreach ($inst in ((new-object System.Diagnostics.PerformanceCounterCategory("network interface")).GetInstanceNames())){
$cur = New-Object system.Diagnostics.PerformanceCounter($cat,$cnt,$inst)
$max = New-Object system.Diagnostics.PerformanceCounter($cat,$cnt2,$inst)
$curnum = $cur.NextValue()
$maxnum = $max.NextValue()
$ObjUtil = New-Object System.Object
$ObjUtil | Add-Member -MemberType NoteProperty -Name "Util" -Value ((( $curnum * 8 ) / $maxnum ) * 100)
$ObjUtil | Add-Member -MemberType NoteProperty -Name "InstanceName" -Value $inst
$ObjUtil
}