Getting Dell Service Tag using WMI

by Bharat Suneja

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

{ 19 comments… read them below or add one }

Evans Tucker October 18, 2005 at 3:29 pm

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!

Reply

Anonymous June 23, 2006 at 4:24 am

Works for PCs as well as servers!

Reply

Anonymous June 23, 2006 at 4:25 am

Works for PCs as well as servers!

Reply

Anonymous February 1, 2007 at 3:46 pm

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

Reply

Bharat Suneja February 1, 2007 at 4:16 pm

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

Reply

Anonymous May 14, 2007 at 1:40 pm

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

Reply

Brian June 28, 2007 at 6:08 pm

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

Reply

Anonymous July 5, 2007 at 5:55 am

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

Reply

Anonymous August 10, 2007 at 2:15 pm

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)

Reply

Anonymous August 22, 2007 at 11:12 am

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

Reply

freemantim February 4, 2008 at 12:47 pm

thanks for the script. handy little tool.

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

Reply

Anonymous June 9, 2008 at 1:53 pm

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

Reply

Anonymous August 15, 2008 at 8:18 am

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

Reply

Vizworld October 10, 2008 at 11:28 pm

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

Reply

Anonymous October 30, 2008 at 10:09 am

@vizworld

Thanks for the quick and easy command!

Reply

Anonymous March 6, 2009 at 5:51 am

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

Wmic bios get serialnumber.

Reply

Tom May 5, 2009 at 2:35 pm

thanks for saving me a trip to the client site!

Reply

Anonymous August 27, 2009 at 2:47 am

PERFECT TY

Reply

cheap computers October 8, 2009 at 3:58 am

Its pretty good.

Reply

Leave a Comment

Previous post:

Next post: