How to gather NIC SpeedDuplex information on Windows machines

book

Article ID: 179897

calendar_today

Updated On:

Products

Inventory Solution

Issue/Introduction

 

Resolution

The following vbscript will gather nic information, including speedduplex on windows clients: 

 

 

 

 

 

On Error Resume Next

' Objects and variables used for the registry data

const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

' Objects and variables used for the WMI data

DIm objWMI, objNA, objNAC, rsNA, rsNAC

Dim strQuery, strDescription, strNICModel, strSpeedDuplex, strSettingID, strComponentID

 

'***************************************************

'Symantec NS7 logic.

'Create instance of Altiris NSE component

dim nse

set nse = WScript.CreateObject ("Altiris.AeXNSEvent")

' Set the header data of the NSE

' Please don't modify this GUID

nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"

nse.Priority = 1

'Create Inventory data block. ***** Please specify the name of an existing data class. *****

dim objDCInstance

set objDCInstance = nse.AddDataClass ("nic_config") ' ***********Please change this dc name.

dim objDataClass

set objDataClass = nse.AddDataBlock (objDCInstance)

'***************************************************

' Main logic to gather wmi & registry data

Set objNetwork = CreateObject("WScript.Network")

strLocalComputer = objNetwork.ComputerName

Set objWMI = GetObject("winmgmts:")

Set rsNA = objWMI.ExecQuery("Select * from Win32_NetworkAdapter where NetConnectionStatus='2'")

For Each objNA in rsNA

strDescription = objNA.Description

strNetConnectionStatus = objNA.NetConnectionStatus

strIndex = objNA.Index

strQuery = "Select * from Win32_NetworkAdapterConfiguration where index=" & strIndex

Set rsNAC = objWMI.ExecQuery(strQuery)

for Each objNAC in rsNAC

 

strSettingID = objNAC.SettingID

 

' Get registry data for this network interface

strNICModel = ""

strSpeedDuplex = ""

strSpeedDuplexDesc = ""

strKeyPath = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}"

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each subKey In arrSubKeys

subKeyPath = strKeyPath & "\" & subKey

objReg.GetStringValue HKEY_LOCAL_MACHINE, subKeyPath, "NetCfgInstanceId", strNetCfgInstanceId

if (strNetCfgInstanceId = strSettingID) Then

objReg.GetStringValue HKEY_LOCAL_MACHINE, subKeyPath, "ComponentID", strComponentID

Select Case strComponentID

Case "pci\ven_15ad&dev_07b0"

strNICModel = "Vmware"

objReg.GetStringValue HKEY_LOCAL_MACHINE, subKeyPath, "*SpeedDuplex", strSpeedDuplex

speedPath = subKeyPath & "\Ndi\Params\*SpeedDuplex\Enum"

objReg.GetStringValue HKEY_LOCAL_MACHINE, speedPath, strSpeedDuplex, strSpeedDuplexDesc

Case "ven_14e4"

strNICModel = "Broadcom"

objReg.GetStringValue HKEY_LOCAL_MACHINE, subKeyPath, "RequestedMediaType", strSpeedDuplex

speedPath = subKeyPath & "\ndi\Params\RequestedMediaType\Enum"

objReg.GetStringValue HKEY_LOCAL_MACHINE, speedPath, strSpeedDuplex, strSpeedDuplexDesc

Case "b06bdrv"

strNICModel = "Broadcom"

objReg.GetStringValue HKEY_LOCAL_MACHINE, subKeyPath, "SpeedDuplex", strSpeedDuplex

speedPath = subKeyPath & "\BRCMndi\Params\*SpeedDuplex\Enum"

objReg.GetStringValue HKEY_LOCAL_MACHINE, speedPath, strSpeedDuplex, strSpeedDuplexDesc

Case "ven_15"

strNICModel = "Vmware"

objReg.GetStringValue HKEY_LOCAL_MACHINE, subKeyPath, "SpeedDuplex", strSpeedDuplex

speedPath = subKeyPath & "\Ndi\Params\*SpeedDuplex\Enum"

objReg.GetStringValue HKEY_LOCAL_MACHINE, speedPath, strSpeedDuplex, strSpeedDuplexDesc

Case "pci\\ven_15ad&dev_07b0"

strNICModel "VMWare"

objReg.GetStringValue HKEY_LOCAL_MACHINE, subKeyPath, "*SpeedDuplex", strSpeedDuplex

speedPath = subKeyPath & "\Ndi\params\*SpeedDuplex\enum"

objReg.GetStringValue HKEY_LOCAL_MACHINE, speedPath, strSpeedDuplex, strSpeedDuplexDesc

Case "ven_8086"

strNICModel = "Intel"

objReg.GetStringValue HKEY_LOCAL_MACHINE, subKeyPath, "SpeedDuplex", strSpeedDuplex

speedPath = subKeyPath & "\Ndi\Params\SpeedDuplex\Enum"

objReg.GetStringValue HKEY_LOCAL_MACHINE, speedPath, strSpeedDuplex, strSpeedDuplexDesc

Case "pci\ven_8086&dev_10f5&subsys_02331028"

strNICModel = "Intel(R) 82567LM Gigabit Network Connection"

objReg.GetStringValue HKEY_LOCAL_MACHINE, subKeyPath, "SpeedDuplex", strSpeedDuplex

speedPath = subKeyPath & "\Ndi\Params\SpeedDuplex\Enum"

objReg.GetStringValue HKEY_LOCAL_MACHINE, speedPath, strSpeedDuplex, strSpeedDuplexDesc

'Wscript.echo " -- " & strSpeedDuplex & " " & strSpeedDuplexDesc & " " & speedPath

Case "pci\ven_8086&dev_1026&subsys_01731028"

strNICModel = "Intel(R) PRO/1000 MT Network Connection"

objReg.GetStringValue HKEY_LOCAL_MACHINE, subKeyPath, "SpeedDuplex", strSpeedDuplex

speedPath = subKeyPath & "\Ndi\Params\SpeedDuplex\Enum"

objReg.GetStringValue HKEY_LOCAL_MACHINE, speedPath, strSpeedDuplex, strSpeedDuplexDesc

Case "*vmnetadapter1"

strNICModel = "VMware Virtual Ethernet Adapter for VMnet1"

strSpeedDuplexDesc = "N/A"

'objReg.GetStringValue HKEY_LOCAL_MACHINE, subKeyPath, "SpeedDuplex", strSpeedDuplex

'speedPath = subKeyPath & "\Ndi\Params\SpeedDuplex\Enum"

'objReg.GetStringValue HKEY_LOCAL_MACHINE, speedPath, strSpeedDuplex, strSpeedDuplexDesc

Case "*vmnetadapter8"

strNICModel = "VMware Virtual Ethernet Adapter for VMnet8"

strSpeedDuplexDesc = "N/A"

'objReg.GetStringValue HKEY_LOCAL_MACHINE, subKeyPath, "SpeedDuplex", strSpeedDuplex

'speedPath = subKeyPath & "\Ndi\Params\SpeedDuplex\Enum"

'objReg.GetStringValue HKEY_LOCAL_MACHINE, speedPath, strSpeedDuplex, strSpeedDuplexDesc

Case Else

strNICModel = "Unknown"

strSpeedDuplexDesc = "Unknown"

End Select

End If

 

Next

Next

 

Wscript.echo "Description ComponentID NetConnectionStatus NICModel SpeedDuplex"

Wscript.echo strDescription & " " & strComponentID & " " & strNetConnectionStatus & " " & strNICModel & " " & strSpeedDuplexDesc

'Wscript.echo "Description: " & strDescription

'Wscript.echo " ComponentID: " & strComponentID

'Wscript.echo " NetConnectionStatus: " & strNetConnectionStatus

'Wscript.echo " NicModel: " & strNICModel

'Wscript.echo " SpeedDuplexDesc: " & strSpeedDuplexDesc

'Wscript.echo ""

'Add a new row

dim objDataRow

set objDataRow = objDataClass.AddRow

'Set columns

objDataRow.SetField 0, strDescription

objDataRow.SetField 1, strComponentID

objDataRow.SetField 2, strNetConnectionStatus

objDataRow.SetField 3, strNICModel

objDataRow.SetField 4, strSpeedDuplexDesc

Next

nse.SendQueued

Attachments

nic_ns7.vbs.txt get_app
nic_ns7.vbs.txt get_app