I am using a script in Altiris to run an inventory and collect info for a custom data class. On most pcs, the script runs and gets the value and then sends to the notification server and database. On some machines, I get an error-...vbs(79,1) (null): Invalid type for data field. On these pcs, the subkey does not exist. I would like the script to either return the value that is expected or just write key not found.
SCRIPT:
'===================================================================================================================
'DESCRIPTION: Gather UEFI Secure Boot Status from client registry and send to Altiris
'===================================================================================================================
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject( "winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Control\SecureBoot\State"
strValueName1 = "UEFISecureBootEnabled"
oReg.GetDWordValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName1,Value
'===================================================================================================================
'Create instance of Altiris NSE component
dim nse
set nse = WScript.CreateObject ("Altiris.AeXNSEvent")
' Set the header data of the NSE
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
'Modify this class guid to match the one generated when you create the custom data class
set objDCInstance = nse.AddDataClass ("{64f22255-aa87-44aa-b088-5c1e93bde22f}")
dim objDataClass
set objDataClass = nse.AddDataBlock (objDCInstance)
'Add a new row
dim objDataRow
set objDataRow = objDataClass.AddRow
'Set columns
objDataRow.SetField 0, Value
'Wscript.Echo UEFISecureBootEnabled
nse.SendQueued
SCRIPT:
'===================================================================================================================
'DESCRIPTION: Gather UEFI Secure Boot Status from client registry and send to Altiris
'===================================================================================================================
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject( "winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Control\SecureBoot\State"
strValueName1 = "UEFISecureBootEnabled"
oReg.GetDWordValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName1,Value
'===================================================================================================================
'Create instance of Altiris NSE component
dim nse
set nse = WScript.CreateObject ("Altiris.AeXNSEvent")
' Set the header data of the NSE
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
'Modify this class guid to match the one generated when you create the custom data class
set objDCInstance = nse.AddDataClass ("{64f22255-aa87-44aa-b088-5c1e93bde22f}")
dim objDataClass
set objDataClass = nse.AddDataBlock (objDCInstance)
'Add a new row
dim objDataRow
set objDataRow = objDataClass.AddRow
'Set columns
objDataRow.SetField 0, Value
'Wscript.Echo UEFISecureBootEnabled
nse.SendQueued