Tuesday, August 23, 2005

WMI: Using WMI to Find Dell Express Service Tags

Need an easy way to determine the express service tag of a Dell machine, or a series of machines? Just copy and past the following code into a *.vbs file, and run it using the following command line: “scriptname.vbs Workstation1 Workstation2…”.

On Error Resume Next
If Wscript.Arguments.Count = 0 Then
Wscript.Echo "Usage: scriptname.vbs workstation1 [ws2] [ws3] ..."
Wscript.Quit
End If

For Each strComputer In Wscript.Arguments
Set objWMIService = GetObject("winmgmts://" & Computer)

If Err.number <> 0 then
Wscript.Echo Computer & ", " & Err.Description
'Err.clear Resets the error code
Err.Clear
else

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
End If

For Each objItem In colItems
Wscript.Echo strComputer &amp; ": " & objItem.SerialNumber
Next
Next

No comments: