Get Network Utilization by Jason Ochoa 28 months ago (modification of post by halr9000 view diff)
View followups from Joel Bennett | diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1352"></script>download | new post
get utilization from all network interfaces
- $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
- }
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