On Nov 7, 8:23 pm, nsoftw...@xxxxxx wrote:
> On Oct 30, 1:42 pm, "Brian H." <hoort...@xxxxxx> wrote:
>
> > I've been digging through WMI trying to figure out how I can check network
> > usage percentages. You know, if you go to the Windows Task Manager,
> > Networking tab, you can see a graph of usage. I'd like to be able to check
> > this remotely via PSH periodically. >
> Just one more note - you can also do this with SNMP.
>
> Lancehttp://geekswithblogs.net/Lance you can start with that (break on Ctrl+C):
$net = new-object
System.Diagnostics.PerformanceCounterCategory("Network Interface")
$name = $net.GetInstanceNames()[1]
$down = New-Object System.Diagnostics.PerformanceCounter("Network
Interface", "Bytes Received/sec", $name)
$up = New-Object System.Diagnostics.PerformanceCounter("Network
Interface", "Bytes Sent/sec", $name)
$dlOld = $down.NextSample().RawValue
$upOld = $up.NextSample().RawValue
while ($true) {
$dlValue = $down.NextSample().RawValue;
$upValue = $up.NextSample().RawValue;
$dlSpeed = $dlValue - $dlOld
$upSpeed = $upValue - $upOld
$dlOld = $dlValue
$upOld = $upValue
write-host -nonewline "down: " ([int]($dlSpeed / 1024)) " up:
" ([int]($upSpeed / 1024))
write-host " " -nonewline
for ($i=0; $i -lt 30; $i++) {
write-host -nonewline "`b"
}
sleep 1
}