While DCM has a vast collection of query modes available to it in order to obtain a setting, there are times where the setting must be calculated or is not found in a consistent location. In that instance, a VBScript option is available to you in order to locate or calculate the setting and return it to DCM for evaluation.
An example of this follows. In this instance, the speed and duplex setting of an Intel NIC needs to ba validated. That setting is stored in the registry of the computer, but not in a consistent location (since it depends on the computer’s configuration and in which order the NIC was enumerated). This script locates the proper registry location and returns the setting to DCM.
'PCI device identifier
DeviceIDs = Array("pci\ven_8086&dev_109a")
'The REG object is how we access and enumerate the
'computer's registry
Set REG = GetObject("winmgmts://./root/default:StdRegProv")
'The constant HKLM gets us access to HKEY_LOCAL_MACHINE
Const HKLM = &H80000002
'All NIC configurations are stored under a particular root key
Root = "SYSTEM\CurrentControlSet\Control\Class\" & _
"{4D36E972-E325-11CE-BFC1-08002bE10318}"
'Enumerate the NIC configuration keys
REG.EnumKey HKLM, Root, ConfigKeys
'Look for the configuration that has a matching PCI device ID
For Each ConfigKey in ConfigKeys
MDID = ""
On Error Resume Next
REG.GetStringValue HKLM, Root & "\" & ConfigKey, _
"MatchingDeviceID", MDID
On Error Goto 0
For Each DID in DeviceIDs
If Left(UCase(MDID),Len(DID)) = UCase(DID) Then
'We have found a match so obtain and print out
'the speed and duplex setting
REG.GetStringValue HKLM, Root & "\" & ConfigKey, _
"SpeedDuplex", SD
WScript.Echo SD
End If
Next
Next
In this case, if there are no matching NICs, no data is output to DCM. You can treat this a zero (0) instance validation. If there is more than one NIC, each setting will be returned on a different line. DCM treats this as multiple instances and evaluates each one individually. If you are doing instance validation, you would want to set it to “at least 1″.
Post a Comment
You must be logged in to post a comment.