I've been working on a VBscript inspired by these posts: http://deployhappiness.com/series/creating-an-inventory-with-active-directory/ and I've found a decent amount of success in my test machines with the Manufacturer, Model Series, MTM, and Serial Number entries. That being said I've run into a brick wall on uploading CPU Name and installed physical memory to the custom attributes(AD atributes like "RAM" "processor" etc.) I have set up. All machines being used for testing these scripts have been given the appropriate SELF permissions to write to these attributes using the scripts and I'm testing them locally on each machine before I put them into a netlogon script.
The code I've been trying to use for both goes something like this, and I've consulted WMIExplorer for guidance without much luck on getting the two scripts to work:
strprocessor= GetCPU
updatecpu(strprocessor)
Function GetCPU
strcomputer = "."
set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strcomputer & "root\cimv2")
set colprocessors = objWMIservice.ExecQuery _
("Select * from Win32_Processor")
For each objprocessor in colprocessors
GetCPU= objprocessor.name
Next
End Function
Sub Updatecpu(strprocessor)
Set objSysInfo = CreateObject("ADSystemInfo")
On Error Resume Next
Set objComputer = GetObject ("LDAP://" & objSysInfo.ComputerName)
objProcessor.name = strprocessor
objComputer.SetInfo
End Sub
And the memory function:
strRAM= GetRAM
updateRAM(strRAM)
Function GetRAM
strComputer = "*"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate} !\\" & strcomputer & "root\cimv2")
set colcomputersystem = objWMIService.ExecQuery _
("Select * from Win32_Computersystem")
For each objcomputersystem in colcomputersystem
GetRAM= objcomputersystem.totalphysicalmemory
Next
End Function
Sub UpdateRAM(strRAM)
Set objSysInfo = CreateObject ("ADSystemInfo")
On Error Resume Next
Set objComputer = GetObject ("LDAP://" & objSysInfo.ComputerName)
objcomputersystem.totalphysicalmemory = strRAM
objComputer.SetInfo
End Sub
By contrast the manufacturer component that worked was formatted almost identically:
Strmanufacturer = getmanufacturer
updatemanufacturer(strmanufacturer)
Function Getmanufacturer
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colcomputersystem = objWMIService.ExecQuery _
("Select * from Win32_computersystem")
For each objcomputersystem in colcomputersystem
Getmanufacturer = objcomputersystem.manufacturer
Next
End Function
Sub Updatemanufacturer(strmanufacturer)
Set objSysInfo = CreateObject("ADSystemInfo")
On Error Resume Next
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
objComputer.manufacturer = strmanufacturer
objComputer.SetInfo
End Sub
I know I had to screw up either an obj or col category here but I haven't been able to figure it out just yet. Any suggestions?