Author Topic: Get Assettag from dell computers  (Read 5086 times)

Orionbelt

  • Newbie
  • *
  • Posts: 24
Get Assettag from dell computers
« on: July 02, 2013, 02:49:13 pm »
How can i get assesttag from dell computers. i got everything else, but couldn't find the way to get assettag...here is my script.
================================
Locator = ObjectOpen("WbemScripting.SWbemLocator")
Service = Locator.ConnectServer()
Security = Service.Security_
Security.ImpersonationLevel = 3
Class = "Win32_ComputerSystemProduct"
Instance = Service.InstancesOf(Class)
Enum = ObjectCollectionOpen(Instance)

Class1 = "Win32_NetworkAdapterConfiguration"
Instance1 = Service.InstancesOf(Class1)
hEnum1 = ObjectCollectionOpen(Instance1)
Obj1 = ObjectCollectionNext(hEnum1)


Obj = ObjectCollectionNext(Enum)
If Obj==0 Then Break
man = Obj.Vendor
model = Obj.Name
serial = Obj.IdentifyingNumber
varName = obj.Name
;ASSETTAG= obj.AssetTagNum

ObjectCollectionClose(Enum)
ObjectClose(Instance)
ObjectClose(Security)
ObjectClose(Service)
ObjectClose(Locator)
=====================================

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Get Assettag from dell computers
« Reply #1 on: July 02, 2013, 02:54:20 pm »
Win32_SystemEnclosure class seems to contain a property called SMBIOSAssetTag that looks interesting. http://msdn.microsoft.com/en-us/library/windows/desktop/aa394474(v=vs.85).aspx

Code: Winbatch
objLocator = ObjectCreate("WbemScripting.SWbemLocator")
objService = objLocator.ConnectServer(".","root/cimv2","","")
objSecurity = objService.Security_
objSecurity.ImpersonationLevel = 3
class =  "Win32_SystemEnclosure"
; query instances
query = "SELECT * FROM ":Class
colInstances = objService.ExecQuery(query)

; loop once for each instance
ForEach objInstance in colInstances
  ;Check if Object is EMPTY
  type = ObjectTypeGet(objInstance)
  if type=="EMPTY" then break
   ; obtain properties
   propCaption = objInstance.Caption
   ;propDescription = objInstance.Description
   ;propManufacturer = objInstance.Manufacturer
   ;propModel = objInstance.Model
   ;propName = objInstance.Name
   ;propSerialNumber = objInstance.SerialNumber
   propSMBIOSAssetTag = objInstance.SMBIOSAssetTag
   ;propStatus = objInstance.Status
   ;propTag = objInstance.Tag
   ;propVersion = objInstance.Version
   Pause(propCaption, propSMBIOSAssetTag)
Next

; close object handles
colInstances = 0
objSecurity = 0
objService = 0
objLocator = 0
Deana F.
Technical Support
Wilson WindowWare Inc.

kdmoyers

  • Sr. Member
  • ****
  • Posts: 349
Re: Get Assettag from dell computers
« Reply #2 on: July 03, 2013, 08:10:54 am »
I found a couple of resources online that said it was actually the "SerialNumber" property, but on my Dell optiplex960, none of these properties work.  Does "SMBIOSAssetTag" or "SerialNumber" work for anyone else?
-Kirby
The mind is everything; What you think, you become.

Orionbelt

  • Newbie
  • *
  • Posts: 24
Re: Get Assettag from dell computers
« Reply #3 on: July 03, 2013, 08:24:19 am »
Deana script works fine on all my dells. I don't have 960...but tested on precision, 790,780,7010,9010.. .......

kdmoyers

  • Sr. Member
  • ****
  • Posts: 349
Re: Get Assettag from dell computers
« Reply #4 on: July 04, 2013, 07:39:30 am »
Hmmm...
The mind is everything; What you think, you become.

therkilt

  • Newbie
  • *
  • Posts: 10
Re: Get Assettag from dell computers
« Reply #5 on: July 25, 2013, 07:22:19 am »
This is the way I have always gotten the asset tag from Dell, HP, IBM, and Panasonic computers:
Code: Winbatch
Asset = `N/A`
Model = `N/A`
Vendor = `N/A`
objLocator = ObjectCreate("WbemScripting.SWbemLocator")
objService = objLocator.ConnectServer(``,`root/cimv2`,``,``)
if objService <> 0
        objSecurity = objService.Security_
        objSecurity.ImpersonationLevel = 3
                class =  "Win32_ComputerSystemProduct"
                query = "SELECT * FROM Win32_ComputerSystemProduct"
                colInstances = objService.ExecQuery(query)
                        if colInstances <> 0 then
                                ForEach objInstance in colInstances
                                        type = ObjectTypeGet(objInstance)
                                        if type=="EMPTY" then break
                                        Asset = StrTrim(objInstance.IdentifyingNumber)
                                        Model = StrTrim(objInstance.Name)
                                        Vendor = StrTrim(objInstance.Vendor)
                                Next
                        endif
                if colInstances <> 0 then ObjectClose(colInstances)
        ObjectClose(objSecurity)
endif
ObjectClose(objService)
ObjectClose(objLocator)

Message(`Results`,StrCat(`Asset = `,Asset,@CRLF,`Model = `,Model,@CRLF,`Vendor = `,Vendor))
 

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Get Assettag from dell computers
« Reply #6 on: July 25, 2013, 08:34:25 am »
This is the way I have always gotten the asset tag from Dell, HP, IBM, and Panasonic computers:
Code: Winbatch
Asset = `N/A`
Model = `N/A`
Vendor = `N/A`
objLocator = ObjectCreate("WbemScripting.SWbemLocator")
objService = objLocator.ConnectServer(``,`root/cimv2`,``,``)
if objService <> 0
        objSecurity = objService.Security_
        objSecurity.ImpersonationLevel = 3
                class =  "Win32_ComputerSystemProduct"
                query = "SELECT * FROM Win32_ComputerSystemProduct"
                colInstances = objService.ExecQuery(query)
                        if colInstances <> 0 then
                                ForEach objInstance in colInstances
                                        type = ObjectTypeGet(objInstance)
                                        if type=="EMPTY" then break
                                        Asset = StrTrim(objInstance.IdentifyingNumber)
                                        Model = StrTrim(objInstance.Name)
                                        Vendor = StrTrim(objInstance.Vendor)
                                Next
                        endif
                if colInstances <> 0 then ObjectClose(colInstances)
        ObjectClose(objSecurity)
endif
ObjectClose(objService)
ObjectClose(objLocator)

Message(`Results`,StrCat(`Asset = `,Asset,@CRLF,`Model = `,Model,@CRLF,`Vendor = `,Vendor))
 

Good Stuff! Thanks for posting. It looks like the IdentifyingNumber property of the Win32_ComputerSystemProduct class seems to do the job.
Deana F.
Technical Support
Wilson WindowWare Inc.