Getting Dell Service Tag using WMI

Need to maintain an accurate inventory of servers in datacenter. Dell servers have a Service Tag that is required when calling Dell support, and it makes sense to include this in the server list.

Here’s how to retrieve the Service Tag from the system BIOS. This uses WMI, and therefore works only on Windows servers.

‘Check for Arguments
If WScript.Arguments.Count = 0 Then
 Wscript.Echo “Usage: GetDesllSvcTag.vbs computer1 [computer2] [computer3] ……”
 WScript.Quit
End If
 
For Each strComputer In wscript.Arguments
Set objWMIService = GetObject(“winmgmts:” _ & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)
Set colSMBIOS = objWMIService.ExecQuery _ (“Select * from Win32_SystemEnclosure”)
For Each objSMBIOS in colSMBIOS
Wscript.Echo strComputer & “: ” & objSMBIOS.SerialNumber
Next
Next

For a Windows PowerShell version, see Get Dell Service Tag Using PowerShell.

The production script I use queries Active Directory, using ADSI, for all computers running Windows Server 2003/2000, gets their OS, Service Pack, and date of computer account creation, then connects to each server using the above method to get the Dell service tag (and other info, such as number of CPUs, RAM, etc.).

To enable others to dynamically generate this list on demand, the script is web-enabled and generates a better formatted web page with the required details (with the ability to click on a server name and drill down to gather further info such as IP configuration, drive space utilization/free space, etc.). The drill-down’s required because:

  • ou can’t put everything in a list on the first page, it would be unreadable – endless scrolling
  • Would involve too many WMI calls to each server after initial Active Directory query, and slow down the list generation to a crawl

Written by

Bharat Suneja

19 Comments

  1. Evans Tucker

    Thank you VERY much for posting this script! I’ve been trying to find a way to get the service tags of all the machines on the network for a couple of hours now – this script is exactly what I was looking for!

  2. Anonymous

    Works for PCs as well as servers!

  3. Anonymous

    Works for PCs as well as servers!

  4. Anonymous

    sorry to sound stupid, but how do you run this script? Thank you for the help in advance.

  5. Bharat Suneja

    Copy the code to notepad and save it with a vbs extension. When saving, make sure the “Save As Type:” is set to “All Files” and not “Text Documents (txt)”.

    Recommend running scripts using cscript – if it’s not your default engine you can use:
    cscript myscriptname.vbs

  6. Anonymous

    If you have problems running it (I did) remove the ” _” from lines 8 and 9.

  7. Brian

    Here’s another take on getting the service tag. This one asks for the host name and gives the resulting service tag in a popup.


    On Error Resume Next
    Dim strComputer
    strComputer = InputBox(“Enter the name of DELL Computer:”)
    Set objWMIService = GetObject(“winmgmts:” & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)
    Set colSMBIOS = objWMIService.ExecQuery (“Select * from Win32_SystemEnclosure”)
    For Each objSMBIOS in colSMBIOS
    MsgBox strComputer & “: ” & objSMBIOS.SerialNumber
    Next

  8. Anonymous

    how would you modify this to get serial number of say HP or IBM machines

  9. Anonymous

    here’s the code that I use to process IBM/LENOVO gear…it’s a snippet of larger program so you might have to do some cleanup.


    Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\CIMV2”)
    Set colItems = objWMIService.ExecQuery( _
    “SELECT * FROM Win32_ComputerSystem”,,48)
    For Each objItem in colItems
    mfg = objItem.Manufacturer
    model = objItem.Model ‘Model
    sysname = LCase(objItem.Name) ‘System Name
    systype = objItem.SystemType ‘System Type

    Set colItems = objWMIService.ExecQuery( _
    “SELECT * FROM Win32_ComputerSystemProduct”,,48)
    For Each objItem in colItems
    machver = objItem.Version ‘Version
    Next

    IF (StrComp(mfg,”LENOVO”) = 0) Then
    sysmodel = Mid(model,1,4)
    systype = Mid(model,4,3)
    End If

    Wscript.Echo(“Vendor: ” + mfg + vbCrLf + “host: ” + sysname + vbCrLf + “OS: ” + osname + vbCrLf + “OS Ver: ” + osver + vbCrLf + “Make: ” + machver + vbCrLf + “Type: ” + systype + vbCrLf + “Model: ” + sysmodel + vbCrLf + “Serial #: ” + serialno)

  10. Anonymous

    Hey dude i tried ur scripts the first one is not working for me incase if u can write a script which generates the service tag along with machine name in my domain it would be wonderfull:)

    – Brijendra Shukla

  11. freemantim

    thanks for the script. handy little tool.

    is there a way to have the output dumped to a CSV file?

  12. Anonymous

    To save the output as a CSV file:

    1- change the line:
    Wscript.Echo strComputer & “: ” & objSMBIOS.SerialNumber

    to:
    Wscript.Echo strComputer & “,” & objSMBIOS.SerialNumber

    2- run the script as:
    cscript myscriptname.vbs > results.csv

    Ronaldo Radunz

  13. Anonymous

    Could this script be reversed, so I could query the Dell service tag to get the computer name?

  14. Vizworld

    Easier method (atleast for me) :). Open a command prompt type in:

    Wmic bios get serialnumber.

    This could be used with remote machines as well.

    wmic /user:administrator /node:machinename bios get serialnumber

  15. Anonymous

    @vizworld

    Thanks for the quick and easy command!

  16. Anonymous

    I’ve been using this one for a long time, it’s so easy!

    Wmic bios get serialnumber.

  17. Tom

    thanks for saving me a trip to the client site!

  18. Anonymous

    PERFECT TY

Leave a Comment

Your email address will not be published. Required fields are marked *