Windows Server TechCenter >
Windows Server Forums
>
Windows PowerShell
>
Convert bytes to MB with Get-counter
Convert bytes to MB with Get-counter
- Hi All
I got this small "script" that gives the network interface trafffic status using powershell v2 CTP 3.
I trying to convert the bytes to MB.
Can soneone help ?
Here is the code:
get-counter -counter "\Network Interface(*)\Bytes Sent/sec", "\Network Interface(*)\Bytes Received/sec" -SampleInterval 6
Simon
Answers
- Try this to the end of your command above:
PS>get-counter ... -sampleinterval 6|select -exp countersamples|ft -a instancename,@{l="value";e={[math]::round($_.cookedvalue/1MB,5)}}- Marked As Answer byMervyn ZhangMSFT, ModeratorMonday, November 09, 2009 6:10 AM
All Replies
- Try this to the end of your command above:
PS>get-counter ... -sampleinterval 6|select -exp countersamples|ft -a instancename,@{l="value";e={[math]::round($_.cookedvalue/1MB,5)}}- Marked As Answer byMervyn ZhangMSFT, ModeratorMonday, November 09, 2009 6:10 AM
- Hi there,
I tried this but it's not doing any thing, here is the full command
get-counter -counter "\Network Interface(*)\Bytes Sent/sec", "\Network Interface(*)\Bytes Received/sec" -sampleinterval 6 |select -exp countersamples|ft -a instancename,@{l="value";e={[math]::round($_.cookedvalue/1MB,5)}}
cheers
simon - Can you show some examples?
Here's the first few lines of output when I run it as above:
InstanceName value
------------ -----
local area connection - virtual network 0
broadcom netlink [tm] fast ethernet 0
internal 0
dell wireless 1505 draft 802.11n wlan mini-card 0.00031 - Hi There, I just get a blank screen. P.S I'm using Powershell v2 CTP3. Simon
Hi There, I just get a blank screen. P.S I'm using Powershell v2 CTP3. Simon
Try taking my last command and trimming it down to see at what point you do get some output.
1. Remove "|ft -a ...".
2. Test.
3. Remove "|select -exp ...".
4. Test.
Let me know...

