Link to home
Start Free TrialLog in
Avatar of Akulsh
AkulshFlag for India

asked on

How to format WMI Query about NIC speed

This command gives me speed of NIC, but it is in bits per sec:
SELECT Speed FROM Win32_NetworkAdapter WHERE NetEnabled=True

So I get output of '1000000000'

How may I convert this output so it shows in Giga bit per sec, and also I wish to display "Gb/s" after it. Thanks.
SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Akulsh

ASKER

Thanks for prompt reply.

Do I need to put '/format' before the round expression?
BTW, I am defining a custom field for BGInfo utility of sysinternals. Thanks again.
It's not a format command so no, num is of course the stored representation of your speed.

Chris
Avatar of Akulsh

ASKER

It is not working, with or without '/format' perhaps since I am defnining a custom field.

I also tried
round("SELECT Speed FROM Win32_NetworkAdapter WHERE NetEnabled=True
" / 1024/1024/1024, 2) & "Gb/s"

and I get the error that field must start with "SELECT..."

It seems to me that I have to append my expression with '/format' but don't know the syntax after that.
Avatar of Bill Prew
Bill Prew

I know how to do what you are asking, but just curious, why aren't you using the built in field <Network Speed> ?

~bp
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Akulsh

ASKER

bp,

I would use the built-in field 'Network Speed' if it would not include all disabled or disconnected NICs. A server may have 4 NICs and only 1 in use, then Network Speed shows 4 lines, with last 3 having 0 Gb/s seed.

About your vbs script, I wil test it later today. Thanks.
Okay, suspected as much on the built in field, but wanted to ask.  The VBS seemed to work well here, hope it does for you as well.

~bp
Avatar of Akulsh

ASKER

bp,

Your vbs files worked like a charm.
BTW, I have created 4 other custom fields in BGInfo for IP address, Subnet mask, DNS servers and Network Adapter, without needing a vbs file. Thanks again. I will close this question shortly.
Avatar of Akulsh

ASKER

bp,

A bit strange behavior when I logon to certain servers. I get the errors (see enclosed) but BGinfo runs successfully. So each time, user has to click on OK -- a real problem. I have not seen this behavior on 3 other servers tested.

By the way, I replaced 1024 by 1000 in script since speed was showing as .93 Gbps. Thanks.
NIC-SpeedVBscriptError-BGInfo.gif
NIC-SpeedVBscriptError2-BGInfo.gif
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Akulsh

ASKER

-bp

Sorry for not getting back earlier.

Your new script helped with a Win 2008 server but not with an old Win 2K3. But that is good enough. Thanks.
Welcome.

~bp
Bill Prew - thanks very much!  this worked like a charm.  I needed to change the way BGinfo referenced NIC info following a XenServer tools update that broke the native BGinfo 4.16 items for "Network Card, Network Speed", etc.  You are the man.
Great.

~bp