well my VB skills are back in the uni days, getting an error with the below for adding the date in:
Code:
Option Explicit
On Error Resume Next
Dim objRootDSE, objNetwork, objWMIService, objComputer
Dim strComputer, strMake, strModel, strSerialNumber, strMacAddresses, strMemory, intMemory
Dim colBIOS, objBIOS
Dim colItems, objItem, strHDD
Dim colNetworkAdapterConfiguration, objNetworkAdapterConfiguration
Dim colComputerSystem, objComputerSystem
Dim colPhysicalMemory, objPhysicalMemory
Dim adoConnection, adoRecordset
Dim myDateString
strComputer = "."
strMemory = ""
strMake = ""
strModel = ""
strSerialNumber = ""
strMacAddresses = ""
myDateString = Date()
Set objRootDSE = GetObject("LDAP://RootDSE")
Set objNetwork = WScript.CreateObject("WScript.Network")
Set objWMIService = GetObject("Winmgmts:\\" & strComputer & "\root\cimv2")
Set colComputerSystem = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
If Not colComputerSystem Is Nothing Then
For Each objComputerSystem In colComputerSystem
strMake = objComputerSystem.Manufacturer
strModel = objComputerSystem.Model
Next
End If
Set colBIOS = objWMIService.ExecQuery("Select * From Win32_BIOS")
If Not colBIOS Is Nothing Then
For Each objBIOS in colBIOS
strSerialNumber = objBIOS.SerialNumber
Next
End If
Set colItems = objWMIService.ExecQuery("Select * From Win32_DiskDrive")
If Not colItems Is Nothing Then
For Each objItem in colItems
strHDD = objItem.Model
Next
End If
Set colPhysicalMemory = objWMIService.ExecQuery("Select * From Win32_PhysicalMemory")
If Not colPhysicalMemory Is Nothing Then
intMemory = 0
For Each objPhysicalMemory In colPhysicalMemory
intMemory = intMemory + Int(objPhysicalMemory.Capacity)
Next
strMemory = (intMemory / 1024 / 1024 / 1024) & " GB"
End If
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
If Err.Number <> 0 Then
MsgBox "Connect Error: " & Err.Description
WScript.Quit
End If
Set adoRecordset = adoConnection.Execute(";(&(objectCategory=Computer)(name=" & objNetwork.Computername & "));adspath;subtree")
If Err.Number <> 0 Then
MsgBox "Query Error: " & Err.Description
WScript.Quit
End If
If Not adoRecordset.EOF Then
Set objComputer = GetObject(adoRecordset.Fields(0).Value)
objComputer.Put "description", "" &strModel & ", HDD: " & strHDD & ", " & strMemory & " RAM" & ", Serial: " & strSerialNumber & ", Date: " myDateString
objComputer.SetInfo
End If
If Err.Number <> 0 Then
MsgBox "Write Error: " & Err.Description
WScript.Quit
End If