Need to find server serial number with VBScript

The following script works great on Dell servers to return tag/serial number information.
How do I use a similar script to get the serial number of HP Proliant DL380 servers?

Dim strComputer, objWMIService, colItems, objItem
strComputer = InputBox("Please enter the computer name or IP Address of a Dell machine:","Computer Name or IP Address")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS",,48)
For Each objItem In colItems
      MsgBox "Dell Service Tag: " & objItem.SerialNumber
MsgBox "Finished"

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The same script should work, but typically depends on that information being populated in the BIOS. There are numerous free products that scan remote systems and return the information. You might try WMI Asset Logger, it is a program that I wrote and is free (no spy/nag). Anyway I'm not here to SPAM the forums so if you want to try just google it.

You might also try getting the asset tag, I know this works for Dell, and HP.....
Use the same code you posted above, changing Win32_BIOS to "Win32_SystemEnclosure" and change
objItem.SerialNumber to objItem.SMBIOSAssetTag. Asset tags are not always included, but they tend to show up on Dells.

Malli BoppeCommented:
If you have loets of HP server I recommend you to setup HP CMS which can do amazing things for you.You can run reports about hardware and find any failed hardware and lot more.

Similar question
lanman777Author Commented:
I think what I am looking for is a return on this "chassisserialnumber" via VBScript.
However, have not been able to get this parameter to successfully return
the serial number of the Proliant DL380 server.
You might try this one, I tried this on my LAN and found a few IBMs that held the serial information in this class, unfortunately I do not have any HP servers (although that truly shouldn't matter, the same IBMs also had the serial number under Win32_BIOS.SerialNumber)

Have you tried to query any other WMI based information from the same system ?

strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_SystemEnclosure",,48) 
For Each objItem in colItems 
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Win32_SystemEnclosure instance"
    Wscript.Echo "-----------------------------------"
    If isNull(objItem.ChassisTypes) Then
        Wscript.Echo "ChassisTypes: "
        Wscript.Echo "ChassisTypes: " & Join(objItem.ChassisTypes, ",")
    End If
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Model: " & objItem.Model
    Wscript.Echo "OtherIdentifyingInfo: " & objItem.OtherIdentifyingInfo
    Wscript.Echo "PartNumber: " & objItem.PartNumber
    Wscript.Echo "SerialNumber: " & objItem.SerialNumber
    Wscript.Echo "SMBIOSAssetTag: " & objItem.SMBIOSAssetTag

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Server OS

From novice to tech pro — start learning today.