Get Assettag from dell computers

Started by Orionbelt, July 02, 2013, 02:49:13 PM

Previous topic - Next topic

Orionbelt

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

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) Select
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

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

Deana script works fine on all my dells. I don't have 960...but tested on precision, 790,780,7010,9010.. .......

kdmoyers

The mind is everything; What you think, you become.

therkilt

This is the way I have always gotten the asset tag from Dell, HP, IBM, and Panasonic computers:
Code (winbatch) Select

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

Quote from: therkilt 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) Select

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.