UNSOLVED

Turranx

updated

19 years ago

T

Turranx

6 Posts

0

82743

August 22nd, 2007 22:00

HOWTO: WMI Script to retrieve Dell hardware info

I struggled for quite a while trying to figure out how to extract hardware information from my Dell servers. Searching the Dell Forums revealed that a lot of people were looking to do the same thing. Answers were far and few between; when they did come, forum patrons were pushed towards using OpenManage Command Line Interface (of which I can't really get excited about).

After a couple hours with my nose inside WMI, I present to you the answers you seek:

Sub Get_Dell_Hardware (ByVal strComputer)
On Error Resume Next
Dim objInstance, colInstances, objProperty
Dim i, strTemp, intStartPosition, intEndPosition

Set colInstances = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2\dell:" & _
"Dell_CMDeviceApplication" ).Instances_

For Each objInstance In colInstances
WScript.Echo String(60,"=" )
For Each objProperty In objInstance.Properties_
intStartPosition = 0
intEndPosition = 0
strTemp = ""
If objProperty.Name = "Antecedent" Then
intStartPosition = InStr(objProperty.Value, "name=" ) + 6
intEndPosition = InStr(intStartPosition,objProperty.Value,Chr(34),1)-intStartPosition
strTemp = mid(objProperty.Value, _
intStartPosition, _
intEndPosition)
WScript.Echo "Device: " & strTemp
End If

intStartPosition = 0
intEndPosition = 0
strTemp = ""
If objProperty.Name = "Dependent" Then
intStartPosition = InStr(objProperty.Value, "name=" ) + 6
intEndPosition = InStr(intStartPosition,objProperty.Value,Chr(34),1)-intStartPosition
strTemp = mid(objProperty.Value, _
intStartPosition, _
intEndPosition)
WScript.Echo vbTab & "Subcomponent Device: " & strTemp
End If

intStartPosition = 0
intEndPosition = 0
strTemp = ""
If objProperty.Name = "Dependent" Then
intStartPosition = InStr(objProperty.Value, "version=" ) + 9
intEndPosition = InStr(intStartPosition,objProperty.Value,Chr(34),1)-intStartPosition
strTemp = mid(objProperty.Value, _
intStartPosition, _
intEndPosition)
If InStr(objProperty.Value, "FRMW" ) > 0 Then
WScript.Echo vbTab & "Firmware Version: " & strTemp
Elseif InStr(objProperty.Value, "DRVR" ) > 0 Then
WScript.Echo vbTab & "Driver Version: " & strTemp
Elseif InStr(objProperty.Value, "APP" ) > 0 Then
WScript.Echo vbTab & "Application Version: " & strTemp
Elseif InStr(objProperty.Value, "BIOS" ) > 0 Then
WScript.Echo vbTab & "BIOS Version: " & strTemp
Else
WScript.Echo vbTab & "Data Not Found"
End If
End If
Next
Next
End Sub

Big thanks to Marcin Policht who showed me how to program with WMI in ways Microsoft couldn't show me. http://www.serverwatch.com/tutorials/article.php/1548421

This was tested against a PowerEdge 1750 Server running Windows Server 2003 SP2 x86. OpenManage Server Administrator 5.1.0 was installed. The script was run from a Windows Vista Ultimate x32 workstation. Both machines are in the same domain. I used my Domain Admin account to run the script.

I received no errors during the running of the code, but due to the way code is displayed on this message forum, you might have an extra line break or other formatting error to fix before it will run right on your workstation. If you have comments, questions, or think you found a bug, lemee know here.

PS. Dell, you really need to add an option to disable emoticons. They show up in my code when I don't want them to. Second, you should consider adding the ability to display code in a forum post without removing the tab/space line formatting.

TAGS: VBS script WMI driver firmware hardware programmatically extract read

Message Edited by Turranx on 08-22-2007 07:59 PM