Thursday, January 17, 2008

Dell Service Tag

I finally got fed up and decided to get more involved in the workstation side of my company simply because it seemed like nobody knew what was going on and what machine was what.  I figured the first step I should take would be an inventory of systems.  Since we are a Dell house I figured the first place would be get the service tag and download from Dell the packing slips.  I needed a quick way to get all of my machines tags without installing SNMP.  I found this script at  It works like a charm.

First, this basic script will get it from "localhost" (please note the second line strComputer = ".")

'------START/Don't include this line------------
on error resume next
strComputer = "."
Set objWMIservice = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colitems = objWMIservice.ExecQuery("Select * from Win32_BIOS",,48)
For each objitem in colitems
     Wscript.echo "Dell Service Tag: " & objitem.serialnumber
'------END/Don't include this line---------------

If you want a pop-up box to input the name of a remote host, you can modify the second line to:
    strComputer=InputBox ("Enter the computer name of the server you'd like to query for Service Tag")

Both versions above can be run like this: "cscript servicetag.vbs"

If you want to use the command line, you can change the second line to:

...and run like this instead: "cscript servicetag.vbs machinename"

If running this against multiple machines (and redirecting output to a text file), you can change the output line (Wscript.echo) to:
    Wscript.echo strComputer & ": " & objitem.serialnumber

...and run like this:
C:\myscripts\> cscript servicetag.vbs machine1 >> outputfile.txt
C:\myscripts\> cscript servicetag.vbs machine2 >> outputfile.txt
C:\myscripts\> cscript servicetag.vbs machine3 >> outputfile.txt
C:\myscripts\> cscript servicetag.vbs machine4 >> outputfile.txt

No comments: