CMS 7 Reboot Inventory for Windows
I have been poking around in the data collected and I did not see any reboot information being gathered, which we use for keeping users in compliance with company policy, so I had to write a new one. (I did play around with the legacy inventory provided with version seven but it crashed more often than not and it did not behave as expected when it did submit data so I bailed and started over.) I never had much luck with pulling the reboot information from the registry because sometimes the registry does not update so I pull the reboot event from the system log. I thought I would share that script with anyone who might be interested.
Caveats:
- You will need to create a custom data class with a single string field for this to work.
- You will need to insert the GUID for the above data class into the script where it is marked below.
- You may also need to change the GUID in the "nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"" line if your NS GUID is different than mine. There are sample custom inventories so you can check one of those to verify the NS GUID. If it is different just cut and paste.
Option Explicit
'On Error Resume Next
Dim objWMIService
Dim propValue
Dim objItem
Dim colItems
Dim nse
Dim objDCInstance
Dim objDataClass
Dim objDataRow
Dim temp1, temp2
'Create instance of Altiris NSE component
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
set objDCInstance = nse.AddDataClass ("{insert custom data class guid}")
set objDataClass = nse.AddDataBlock (objDCInstance)
'Fire WMI Query
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NTLogEvent where logfile='system' and eventcode='6005'")
For Each objItem in colItems
temp2 = objItem.TimeGenerated
If temp1 = "" Then
temp1 = temp2
ElseIf temp2 > temp1 Then
temp1 = temp2
End If
Next
'Set columns
set objDataRow = objDataClass.AddRow
objDataRow.SetField 0, temp1
nse.SendQueued
Hope this saves someone some time.
Nice!
I was looking at doing something similar for our NS6 environment; hadn't quite gotten to the point of writing up the WMI query, but you did it for me! Thanks!
We have another query that seems to work most of the time but again relies on WMI and the system Performance counters (which sometimes are corrupted). It writes the data to the registry in the ADO ISO/8601 format which is then collected by custom inventory.
Thanks,
Kyle
Symantec Trusted Advisor
If your question has been resolved, please be sure to click "Mark as Solution"! Thank you.
Would you like to reply?
Login or Register to post your comment.