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)
=====================================
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
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
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
Deana script works fine on all my dells. I don't have 960...but tested on precision, 790,780,7010,9010.. .......
Hmmm...
This is the way I have always gotten the asset tag from Dell, HP, IBM, and Panasonic computers:
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))
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:
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.