Solved

Need WMI IP info and Network Adapter Speed together

Posted on 2007-03-27
4
893 Views
Last Modified: 2013-12-04
I need to pull the ip, subnet, dns, wins (etc.) and speed settings for each enabled network card.  The problem is adapter speed is in a different WMI class (Win32_NetworkAdapter) than IP info (Win32_NetworkAdapaterConfiguration) and I don't know how to script it to pull the speed into the output of the ip info being requested at point in the loop.  Thanks for any help you can give.

I would like the output to look like this

==========================================
Computer: Jsmith
==========================================
Caption: [00000006] Broadcom 570x Gigabit Integrated Controller
DefaultIPGateway: 192.168.1.1
Description: Broadcom NetXtreme Gigabit Ethernet Driver
DHCPEnabled: True
DHCPServer: 192.168.1.1
DNSServerSearchOrder: 192.168.1.1
Index: 6
IPAddress: 192.168.1.100
IPEnabled: True
IPSubnet: 255.255.255.0
MACAddress: 00:0F:1F:A6:AF:DA
WINSPrimaryServer:
MAX Speed: 100 Mbs          <-----  Need to add this.

-----------------------------------------------------------------------------------
 Here is what I have now (thanks to other experts here and scriptomatic).  Replace COMPUTERNAME for the computer you are pulling the info from.
-----------------------------------------------------------------------------------

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("COMPUTERNAME")
For Each strComputer In arrComputers
   WScript.Echo
   WScript.Echo "=========================================="
   WScript.Echo "Computer: " & strComputer
   WScript.Echo "=========================================="

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration where IPEnabled = 'TRUE'", "WQL",wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
      WScript.Echo "Caption: " & objItem.Caption
      strDefaultIPGateway = Join(objItem.DefaultIPGateway, ",")
         WScript.Echo "DefaultIPGateway: " & strDefaultIPGateway
      WScript.Echo "Description: " & objItem.Description
      WScript.Echo "DHCPEnabled: " & objItem.DHCPEnabled
      WScript.Echo "DHCPServer: " & objItem.DHCPServer
      strDNSDomainSuffixSearchOrder = Join(objItem.DNSDomainSuffixSearchOrder, ",")
      strDNSServerSearchOrder = Join(objItem.DNSServerSearchOrder, ",")
         WScript.Echo "DNSServerSearchOrder: " & strDNSServerSearchOrder
      WScript.Echo "Index: " & objItem.Index
      strIPAddress = Join(objItem.IPAddress, ",")
         WScript.Echo "IPAddress: " & strIPAddress
      WScript.Echo "IPEnabled: " & objItem.IPEnabled
      strIPSubnet = Join(objItem.IPSubnet, ",")
         WScript.Echo "IPSubnet: " & strIPSubnet
      strIPXFrameType = Join(objItem.IPXFrameType, ",")
      WScript.Echo "MACAddress: " & objItem.MACAddress
      WScript.Echo "WINSPrimaryServer: " & objItem.WINSPrimaryServer
      WScript.Echo "-------------------------------------------------------------------------------------------------------"
   Next
Next


Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
      WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
      Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
      & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function
0
Comment
Question by:ewattnem
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 71

Expert Comment

by:Chris Dent
ID: 18800982

Index on the Configuration is linked to DeviceID on the Adapter. These are normally the same, where they aren't the link between the two is in Win32_NetworkAdapterSetting.

You also need to watch what you're getting back from Win32_NetworkAdapterConfiguration as it also returns a lot of less useful things.

I need to head home, but if you haven't had any feedback by the time I get there I'll show you the lot.

Chris
0
 
LVL 71

Accepted Solution

by:
Chris Dent earned 500 total points
ID: 18801059

I take it back, I did have time. I'm not really able to fully test this, none of mine return Max Speed.


On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
      
arrComputers = Array("UKH014884")

For Each strComputer In arrComputers
      WScript.Echo
      WScript.Echo "=========================================="
      WScript.Echo "Computer: " & strComputer
      WScript.Echo "=========================================="

      Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
      Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration " &_
            "WHERE IPEnabled = 'TRUE'", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)

      For Each objItem In colItems
            WScript.Echo "Caption: " & objItem.Caption
            strDefaultIPGateway = Join(objItem.DefaultIPGateway, ",")
                  WScript.Echo "DefaultIPGateway: " & strDefaultIPGateway
            WScript.Echo "Description: " & objItem.Description
            WScript.Echo "DHCPEnabled: " & objItem.DHCPEnabled
            WScript.Echo "DHCPServer: " & objItem.DHCPServer
            strDNSDomainSuffixSearchOrder = Join(objItem.DNSDomainSuffixSearchOrder, ",")
            strDNSServerSearchOrder = Join(objItem.DNSServerSearchOrder, ",")
                  WScript.Echo "DNSServerSearchOrder: " & strDNSServerSearchOrder
            WScript.Echo "Index: " & objItem.Index
            strIPAddress = Join(objItem.IPAddress, ",")
                  WScript.Echo "IPAddress: " & strIPAddress
            WScript.Echo "IPEnabled: " & objItem.IPEnabled
            strIPSubnet = Join(objItem.IPSubnet, ",")
                  WScript.Echo "IPSubnet: " & strIPSubnet
            strIPXFrameType = Join(objItem.IPXFrameType, ",")
            WScript.Echo "MACAddress: " & objItem.MACAddress
            WScript.Echo "WINSPrimaryServer: " & objItem.WINSPrimaryServer

            strIndex = objItem.Index

            Set colNIC = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter " &_
                  "WHERE DeviceID='" & strIndex & "'", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)

            For Each objNIC in colNIC
                  WScript.Echo "Max Speed: " & objNIC.MaxSpeed
            Next

            Set colNIC = Nothing

            WScript.Echo "-------------------------------------------------------------------------------------------------------"
      Next
Next


Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
            WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
            Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
            & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function
0
 

Author Comment

by:ewattnem
ID: 18801533
Brilliant!  It pulled the max speed off my notebook.  I just need to figure out how to work out to pull the correct information from a server that is using HP Teaming.  I'll sort that out but for now you figured out my question so you get the points.  Thanks!!!!!!!!!
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 18801788

You're welcome :)
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An article on effective troubleshooting
This article summaries thoughts and ideas from two years of sustained use. It provides good reasoning to make the jump to Windows 10.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question