Hi,
We are trying to fetch Machine reboot time data from WMI using Custom Inventory. However, getting an error (attached for reference). When tried the script separately it works fine, however, its not populating the data in table coz of the attached error.
Have also tried using the datatype for Data Class as Date, Int and String still same error.
'***************************************************
'**********************************************************************
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOS in colOperatingSystems
dtmBootup = objOS.LastBootUpTime
dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
'dtmSystemUptime = DateDiff("h", dtmLastBootUpTime, Now)
Wscript.Echo dtmLastBootupTime
Next
Function WMIDateStringToDate(dtmBootup)
WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & _
Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) _
& " " & Mid (dtmBootup, 9, 2) & ":" & _
Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup,13, 2))
End Function
'***************************Create instance of Altiris NSE component******************
'*************************************************************************************
dim nse
set nse = WScript.CreateObject ("Altiris.AeXNSEvent")
' **********Set the header data of the NSE***********
' **********Please don't modify this GUID************
nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
nse.Priority = 1
'**************Create Inventory data block. Here assumption is that the data class with below guid is already configured on server*************
dim objDCInstance
'**************Check GUID for the custom dataclass --> next line ("Paste guid here")***************
set objDCInstance = nse.AddDataClass ("{c31c0071-3d8a-4eda-9be0-c44ab570c0df}")
dim objDataClass
set objDataClass = nse.AddDataBlock (objDCInstance)
'*********Add a new row**********
dim objDataRow
set objDataRow = objDataClass.AddRow
'*************Set columns***********
objDataRow.SetField 0,dtmLastBootupTime
nse.SendQueued
Any help / guidance on this would be great...
Thanks in advance.