ewattnem
asked on
Need WMI IP info and Network Adapter Speed together
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_NetworkAdapaterConf iguration) 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("S ELECT * FROM Win32_NetworkAdapterConfig uration where IPEnabled = 'TRUE'", "WQL",wbemFlagReturnImmedi ately + wbemFlagForwardOnly)
For Each objItem In colItems
WScript.Echo "Caption: " & objItem.Caption
strDefaultIPGateway = Join(objItem.DefaultIPGate way, ",")
WScript.Echo "DefaultIPGateway: " & strDefaultIPGateway
WScript.Echo "Description: " & objItem.Description
WScript.Echo "DHCPEnabled: " & objItem.DHCPEnabled
WScript.Echo "DHCPServer: " & objItem.DHCPServer
strDNSDomainSuffixSearchOr der = Join(objItem.DNSDomainSuff ixSearchOr der, ",")
strDNSServerSearchOrder = Join(objItem.DNSServerSear chOrder, ",")
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(dtmDat e)
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
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("S
For Each objItem In colItems
WScript.Echo "Caption: " & objItem.Caption
strDefaultIPGateway = Join(objItem.DefaultIPGate
WScript.Echo "DefaultIPGateway: " & strDefaultIPGateway
WScript.Echo "Description: " & objItem.Description
WScript.Echo "DHCPEnabled: " & objItem.DHCPEnabled
WScript.Echo "DHCPServer: " & objItem.DHCPServer
strDNSDomainSuffixSearchOr
strDNSServerSearchOrder = Join(objItem.DNSServerSear
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(dtmDat
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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!!!!!!!!!
You're welcome :)
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_NetworkAdapterSettin
You also need to watch what you're getting back from Win32_NetworkAdapterConfig
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