Lenovo WinComputer PropertyBagBase Repository

IBM.WinComputer.PropertyBagBase.Repository (ProbeActionModuleType)

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityPublic
RunAsDefault
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
PassThrough ProbeAction System.PassThroughProbe Default
Script ProbeAction Microsoft.Windows.ScriptPropertyBagProbe Default

Source Code:

<ProbeActionModuleType ID="IBM.WinComputer.PropertyBagBase.Repository" Accessibility="Public" Batching="false" PassThrough="false">
<Configuration>
<xsd:element name="ScriptName" type="xsd:string"/>
<xsd:element name="Arguments" type="xsd:string"/>
<xsd:element name="ScriptBody" type="xsd:string"/>
<xsd:element name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="PassThrough" TypeID="System!System.PassThroughProbe"/>
<ProbeAction ID="Script" TypeID="Windows!Microsoft.Windows.ScriptPropertyBagProbe">
<ScriptName>$Config/ScriptName$</ScriptName>
<Arguments>$Config/Arguments$</Arguments>
<ScriptBody><Script>

'Debug Log Definition
Const HKEY_LOCAL_MACHINE = &amp;H80000002
Const DEBUG_INFO_KEY = "SOFTWARE\Lenovo\Lenovo SCOM MP\Debug"
Const DEBUG_LEVEL_NAME = "Level"
Const ERROR_LEVEL = 1
Const WARNING_LEVEL = 2
Const WARNING_LEVEL_DEV = 3
Const INFO_LEVEL = 4
Const INFO_LEVEL_FUNCTION = 5
Const INFO_LEVEL_DETAIL = 6

Const DEVICEID1 = "Tag="""
Const DEVICEID2 = "DeviceId="""
Const DEVICEID3 = "DeviceID="""
Const DEVICEID4 = "deviceID="""
Const STORAGEID = "AllStorage"

'WMI Macro Definition
Const CIMV2_NAMESPACE = "root/cimv2"
Const WMI_NAMESPACE = "root/wmi"
Const SMBIOS_TABLE_WMI_CLASS = "MSSmBios_RawSMBiosTables"
const IPMI_SMBIOS_RECORD_TYPE = 38
Const OS_CIMV2_CLASS = "Win32_OperatingSystem"
Const PNPENTITY_CIMV2_CLASS = "Win32_PnPEntity"
'WMI Macro Definition for all Management Software
'For Director Core Service
Const IBMSD_NAMESPACE = "root/ibmsd"
Const DA_IBMSD_CLASS = "IBMPSG_DirectorAgent"

Const SERVICE_CIMV2_CLASS = "Win32_Service"
Const DRIVER_CIMV2_CLASS = "Win32_SystemDriver"
Const COMPONENTHEALTH_IBMSD_CALSS = "IBMPSG_ComponentHealth"

Const WINEVENT_LICENSE_KEY = "SOFTWARE\Lenovo\Lenovo SCOM MP\LicenseValidate"
Const WINEVENT_LICENSE_NAME = "LicensedValue"

Const IBMHWMP_LICENSE_KEY = "SOFTWARE\IBM\Systems Management Integrations\LicenseEndpoint"
Const LenovoHWMP_LICENSE_KEY = "SOFTWARE\Lenovo\Systems Management Integrations\LicenseEndpoint"
Const IBMHWMP_LICENSE_TOKEN_NAME = "v1-0002.A"
Const IBMHWMP_LICENSE_LEVEL = "Level"
'For BMC Enablement
'For RSA Enablement
'For ServeRAID Agent
Const WINDOWS_INFO_KEY = "SOFTWARE\Microsoft\Windows\CurrentVersion"
Const WINDOWS_PROGRAMFILE_DIR_X86 = "ProgramFilesDir (x86)"
Const SOFTWARE_NODE_X86 = "SOFTWARE\Wow6432Node\"
Const SOFTWARE_NODE = "SOFTWARE\"
Const DA_INFO_KEY_5_10 = "IBM\Director\ExtInfo\ServeRAID Manager Agent"
Const DA_INFO_KEY_5_20 = "IBM\Director\ExtInfo\ServeRAID Manager Level-1 Agent"
Const DA_INFO_KEY_SR_6 = "IBM\Director\Platform\Extension\ServeRAID Manager Level-1 Agent"
Const DA_EXTENSION_NAME = "ExtensionName"
Const DA_INFO_KEY_MR = "IBM\SBMA_MR"
Const DA_LIBLOCATION = "LibLocation"

Const SW_IBM_DA = 1
Const SW_OSA_IPMI = 2
Const SW_IBM_IPMILAYER = 3
Const SW_MS_IPMI = 4
Const SW_IBM_RSA = 5
Const SW_IBM_SERVERAID = 6

Const INTERNAL_ID_IBM_DA = "IBM Director Platform Agent (Core Services, or Level-1 Agent)"
Const INTERNAL_ID_OSA_IPMI = "Avocent/OSA IPMI Driver"
Const INTERNAL_ID_IBM_IPMILAYER = "IBM IPMI Mapping Layer"
Const INTERNAL_ID_MS_IPMI = "Microsoft IPMI Stack"
Const INTERNAL_ID_IBM_RSA = "IBM RSA-II Daemon"
Const INTERNAL_ID_IBM_SERVERAID = "ServeRAID-8x/7x/6x Manager Level-1 Agent"
Const INTERNAL_ID_IBM_MEGARAID = "ServeRAID-MR/BR/IR CIM/WMI Provider"

Const PCI_INFO = 0
Const DEVICE_NAME = 1

Dim ServeRAIDPCIInfoTable
ServeRAIDPCIInfoTable = Array( Array("PCI\VEN_9005&amp;DEV_0286", "ServeRAID-8k/8k-l"),_
Array("PCI\VEN_9005&amp;DEV_0285", "ServeRAID-8s/8i/7t"),_
Array("PCI\VEN_9005&amp;DEV_0279", "ServeRAID-6m"),_
Array("PCI\VEN_9005&amp;DEV_0250", "ServeRAID-6m"))

' DEV_0286 ------ ServeRAID-8k/8k-l
' DEV_0285 ------ ServeRAID-8s/8i/7t
' DEV_0279 ------ ServeRAID-6m
' DEV_0250 ------ ServeRAID-6m

Dim MegaRAIDPCIInfoTable
'"ServeRAID-MR 10i/10k/10m/10ie/10il/10is"
MegaRAIDPCIInfoTable = Array( Array("PCI\VEN_1000&amp;DEV_0060", "ServeRAID-MR 10i/10k/10m"),_
Array("PCI\VEN_1000&amp;DEV_0411", "LSI MegaRAID 8480"))

' DEV_0060 ------ ServeRAID-MR 10i/10k/10e/10m
' DEV_0411 ------ LSI MegaRAID 8480

Dim IntegratedRAIDPCIInfoTable
'IntegratedRAIDPCIInfoTable = Array( Array("PCI\VEN_1000&amp;DEV_0050", "LSI 1064 SAS"),_
' Array("PCI\VEN_1000&amp;DEV_0054", "LSI 1068 SAS"),_
' Array("PCI\VEN_1000&amp;DEV_0056", "LSI 1064E SAS"),_
' Array("PCI\VEN_1000&amp;DEV_0058", "LSI 1068E SAS"),_
' Array("PCI\VEN_1000&amp;DEV_0062", "LSI 1078 SAS"))
IntegratedRAIDPCIInfoTable = Array( Array("PCI\VEN_1000&amp;DEV_0050", "LSI 1064 SAS"),_
Array("PCI\VEN_1000&amp;DEV_0054", "LSI 1068 SAS"),_
Array("PCI\VEN_1000&amp;DEV_0056", "ServeRAID-BR10il"),_
Array("PCI\VEN_1000&amp;DEV_0058", "ServeRAID-BR10i"),_
Array("PCI\VEN_1000&amp;DEV_0062", "LSI 1078 SAS"))
'http://www.redbooks.ibm.com/abstracts/tips0054.html?Open#BR10i

'Feature SR-MR10M SR-MR10k SR-MR10i SR-MR10il SR-MR10is SR-MR10ie SR-BR10i SR-BR10il
'Processor LSI 1078e LSI 1078e LSI 1078e LSI 1078e LSI 1078DE LSI 1078 LSI 1068e LSI 1064e

'DEV_0050, "LSI Adapter, SAS 3000 series, 4-port with 1064 -StorPort"
'DEV_0054, "LSI Adapter, SAS 3000 series, 8-port with 1068 -StorPort"
'DEV_0056, "LSI Adapter, SAS 3000 series, 4-port with 1064E -StorPort"
'DEV_0058, "LSI Adapter, SAS 3000 series, 8-port with 1068E -StorPort"
'DEV_0062, "LSI Adapter, SAS 3000 series, 8-port with 1078 -StorPort"


' Reference SCM_2.2_Support_Matrix_04-28-08.xls
' from Hui SH Yang/China/IBM 2009-07-14 09:38
'ServeRAID-AR10is - Bletchley Park ----megaraid-sas
'ServeRAID-MR10i - Fareham ----megaraid-sas
'ServeRAID-MR10k - Elliot Key ----megaraid-sas
'ServeRAID-MR10M - Morgantown ----megaraid-sas
'ServeRAID-MR10il - Richwood ----megaraid-sas
'Stingray ----megaraid-sas
'Blade SAS Connectivity Card - Meteor ----mptsas
'Blade SAS Expansion Card - Raleigh ----mptsas
'LSI 1064 SAS ----mptsas
'LSI 1064e SAS ----mptsas
'LSI 1078 SAS ----mptsas
'LSI SAS HBA - Winterhaven ----mptsas
'SAS/SATA RAID Kit - Tempest ----mptsas
'SAS/SATA RAID Kit - Tempest+ ----mptsas
'ServeRAID-BR10i - Ruskin ----mptsas
'ServeRAID-BR10ie - Leadville ----mptsas


Dim oAPI, oBag, swFlag

Dim debug, oReg,RC_Code, ScriptName, EventID

ScriptName = "$Config/ScriptName$"

SetLocale("en-us")

debug = -1
Set oReg = GetObject("winmgmts://localhost/root/default:StdRegProv")
If (not(oReg is nothing)) Then
RC_Code = oReg.GetStringValue(HKEY_LOCAL_MACHINE, DEBUG_INFO_KEY, DEBUG_LEVEL_NAME, debug)
If ( RC_Code&lt;&gt;0) Then
debug = -1
End If
End If
Set oAPI = SCOMCreateObject("MOM.ScriptAPI")

$Config/ScriptBody$

Sub LogDebugString(debugString, debugLevel)

If (Int(debug) &gt;= Int(debugLevel)) Then
Call oAPI.LogScriptEvent(ScriptName, EventID, DebugLevelToLogLevel(debugLevel), debugString)
End If

End Sub
Function DebugLevelToLogLevel(debugLevel)
DebugLevelToLogLevel = 4
If debugLevel &lt;= 1 then
DebugLevelToLogLevel = 1
ElseIF debugLevel &lt;= 3 then
DebugLevelToLogLevel = 2
Else
DebugLevelToLogLevel = 4
End If
End Function
Function IsRSAIIDaemonHealthy()
Call LogDebugString("Entering IsRSAIIDaemonHealthy", INFO_LEVEL_FUNCTION)
IsRSAIIDaemonHealthy = -1

Dim iResult, oSWCollection, oObjectItem

iResult = GetWMIObjectCollection(CIMV2_NAMESPACE, SERVICE_CIMV2_CLASS, oSWCollection)
If (iResult &gt; 0) Then
For Each oObjectItem in oSWCollection
If InStr(oObjectItem.Name, "ibmspsvc") &lt;&gt; 0 Then
If Instr(oObjectItem.State, "Running") &lt;&gt; 0 Then
Call LogDebugString("RSAII Daemon Healthy", INFO_LEVEL_DETAIL)
IsRSAIIDaemonHealthy = 1
Exit For
End If
End If
Next
End If

If IsRSAIIDaemonHealthy = -1 Then
Call LogDebugString("RSAII Daemon not Healthy!", INFO_LEVEL)
End If
End Function

Function BMCPresented()
Dim bWS08, bInACPI, bInSMBIOS
Dim osVersion, spVersion
Dim oObjectItem, oManagementTargetCollection, iResult
Const BMC_ACPIINFO = "ACPI\IPI"

Call LogDebugString("Entering BMCPresented", INFO_LEVEL_FUNCTION)

bWS08 = -1
bInACPI = -1
bInSMBIOS = -1

BMCPresented = -1
osVersion = ""
spVersion = ""

If GetOSInfo(osVersion, spVersion) &lt; 0 Then
Call LogDebugString("Could not get OS Info", ERROR_LEVEL)
End If
If(StrComp(osVersion, "6.0.0000") &gt;= 0) Then
'Windows 2008 or later
Call LogDebugString("OS is Windows 2008 or later", INFO_LEVEL_DETAIL)
bWS08 = 1
End If

iResult = GetWMIObjectCollection(CIMV2_NAMESPACE, PNPENTITY_CIMV2_CLASS, oManagementTargetCollection)
If (iResult &gt; 0) Then
For Each oObjectItem in oManagementTargetCollection
If (InStr(CStr(oObjectItem.DeviceID), BMC_ACPIINFO) &lt;&gt; 0) Then
'BMCPresented = 1
bInACPI = 1
Call LogDebugString("BMC Presented in ACPI", INFO_LEVEL_DETAIL)
Exit For
End If
Next
End If

iResult = GetWMIObjectCollection(WMI_NAMESPACE, SMBIOS_TABLE_WMI_CLASS, oManagementTargetCollection)
If (iResult &gt; 0 ) Then
iResult = wmiRawSMBiosCountRecords( oManagementTargetCollection, IPMI_SMBIOS_RECORD_TYPE )
If iResult &gt; 0 Then
'BMCPresented = 2
bInSMBIOS = 1
Call LogDebugString("BMC Presented in SMBIOS, but BIOS need update", INFO_LEVEL_DETAIL)

End If
End If

If bWS08 &gt; 0 And bInACPI &gt; 0 Then
BMCPresented = 1
ElseIf bWS08 &gt; 0 And bInACPI &lt; 0 And bInSMBIOS &gt; 0 Then
BMCPresented = 3 ' need update
ElseIf bWS08 &lt; 0 And bInSMBIOS &gt; 0 Then
BMCPresented = 2
End If

If BMCPresented &lt;0 Then
Call LogDebugString("BMC not Presented", INFO_LEVEL)
End If
End Function

Function GetOSInfo(ByRef osVersion, ByRef spVersion)
Call LogDebugString("Entering GetOSInfo", INFO_LEVEL_FUNCTION)
GetOSInfo = -1

Dim iResult, oCollection, oObjectItem
'Get OS and SP version info
iResult = GetWMIObjectCollection(CIMV2_NAMESPACE, OS_CIMV2_CLASS, oCollection)
If (iResult &gt; 0) Then
For Each oObjectItem in oCollection
If InStr(oObjectItem.Manufacturer, "Microsoft Corporation") &lt;&gt; 0 Then
osVersion = oObjectItem.Version
spVersion = oObjectItem.ServicePackMajorVersion
GetOSInfo = 1
Exit For
End If
Next
Else
Call LogDebugString("Could not get OS Info", ERROR_LEVEL)
End If
End Function

Function IsWin2k3r2()
Call LogDebugString("Entering IsWin2k3r2", INFO_LEVEL_FUNCTION)
IsWin2k3r2 = 0

Dim iResult, oCollection, oObjectItem, osVersion
'Get OS and SP version info
iResult = GetWMIObjectCollection(CIMV2_NAMESPACE, OS_CIMV2_CLASS, oCollection)
If (iResult &gt; 0) Then
For Each oObjectItem in oCollection
If InStr(oObjectItem.Manufacturer, "Microsoft Corporation") &lt;&gt; 0 Then
osVersion = oObjectItem.Version
if ( IsRegExpMatched(osVersion, "^5\.2\.") ) then
If InStr(oObjectItem.OtherTypeDescription, "R2") Then
IsWin2k3r2 = 1
Call LogDebugString("IsWin2k3r2 - Win2k3 r2 - osVersion: " &amp; oObjectItem.Version &amp; _
" - R number: " &amp; oObjectItem.OtherTypeDescription &amp; _
" - SP: " &amp; oObjectItem.ServicePackMajorVersion, INFO_LEVEL_DETAIL)
Exit For
End If
End If
End If
Next
Else
Call LogDebugString("IsWin2k3r2 - Could not get OS Info", WARNING_LEVEL)
End If
Call LogDebugString("End of IsWin2k3r2 - Return: " &amp; IsWin2k3r2, INFO_LEVEL_FUNCTION)
End Function

' [d504936/byou: added for AddIncompatibleBag()]
Function RSAPresented()
Call LogDebugString("Entering RSAPresented", INFO_LEVEL)
RSAPresented = -1

Dim oObjectItem, oManagementTargetCollection, iResult
Const RSA_USBINFO_NOSTORAGE = "USB\VID_04B3&amp;PID_4001"
Const RSA_USBINFO_WSTORAGE = "USB\VID_04B3&amp;PID_4003"

iResult = GetWMIObjectCollection(CIMV2_NAMESPACE, PNPENTITY_CIMV2_CLASS, oManagementTargetCollection)
If (iResult &gt; 0) Then
For Each oObjectItem in oManagementTargetCollection
If (InStr(CStr(oObjectItem.DeviceID), RSA_USBINFO_NOSTORAGE) &lt;&gt; 0) or (InStr(CStr(oObjectItem.DeviceID), RSA_USBINFO_WSTORAGE) &lt;&gt; 0) Then
RSAPresented = 1
Call LogDebugString("RSA Presented", INFO_LEVEL)
Exit Function
End If
Next
End If
Call LogDebugString("RSA not Presented", INFO_LEVEL)
End Function

Function wmiRawSMBiosCountRecords( colRawSMBIOSes, thisRecordType )

dim nMatches
nMatches = 0

dim smbiosTable
for each smbiosTable in colRawSMBIOSes

dim tableData, tablePos, tableSize
tableData = smbiosTable.SMBiosData
tablePos = 0
tableSize = smbiosTable.Size

dim recordType, recordLen, recordHnd
do while ( tablePos &lt; tableSize )
' Look up the type in the formatted section.
recordType = tableData( tablePos )
recordLen = tableData( tablePos+1 )
recordHnd = tableData( tablePos+3 )*256 + tableData( tablePos+2 )

'g_oLOG.LogTrace( "smbios record (pos " &amp; tablePos &amp; "): " &amp; _
' "type = " &amp; recordType &amp; ", " &amp; _
' "len = " &amp; recordLen &amp; ", " &amp; _
' "handle = " &amp; recordHnd )

if ( recordType = thisRecordType ) then
nMatches = nMatches + 1
end if
tablePos = tablePos + recordLen

' Skip over the unformatted section (of null-terminated strings).
do
do until ( tableData(tablePos) = 0 )
tablePos = tablePos + 1
loop
tablePos = tablePos + 1 ' Skip the string terminater.
if ( tableData(tablePos) = 0 ) then
exit do ' Now the string sec terminates.
end if
tablePos = tablePos + 1 ' Skip the 1st (non-null) char.
loop
tablePos = tablePos + 1 ' Skip the section terminator.
loop

' g_oLOG.LogTrace( "smbios table ends at pos " &amp; tablePos &amp; _
' " (size = " &amp; tableSize &amp; ")" )

next

wmiRawSMBiosCountRecords = nMatches

End Function


Function GetAccurateName(ByVal RawName)
'This function is used to remove the """ characters in the file's name string
'Input "xxxxxxxx.xxx"
'Output xxxxxxxx.xxx
Dim tmpName,Name
tmpName = Replace(RawName, """", " ")
Call LogDebugString(tmpName, INFO_LEVEL)
Name = Trim(tmpName)
GetAccurateName = Name
End Function

Function IsRegExpMatched(ByVal strTarget, ByVal strRegExp)
'This function is to see if the specified string matches the given regular expression;
'it returns True if matched; False if not.

IsRegExpMatched = -1

Dim oRegExp
Set oRegExp = New RegExp
oRegExp.IgnoreCase = False
oRegExp.Pattern = strRegExp

IsRegExpMatched = oRegExp.Test(strTarget)
End Function

Function GetWMIObjectCollection(ByVal oNameSpace, ByVal oClassName, ByRef oObjectCollection)

Call LogDebugString("Entering GetWMIObjectCollection(" + oNameSpace + ":" + oClassName + ")", INFO_LEVEL)
GetWMIObjectCollection = -1
Dim e
Set e = New Error
On Error Resume Next
Set oObjectCollection = GetObject("winmgmts:{impersonationLevel=impersonate}//" &amp; _
"." &amp; "/" &amp; oNameSpace &amp; ":" &amp; oClassName).Instances_

'Check WMI communications...
If (oObjectCollection is nothing) Then
Call LogDebugString("No " + oClassName + " class in the namespace", WARNING_LEVEL_DEV)
Exit Function
End If

If (oObjectCollection.Count = 0) Then 'Try to count system instances...
Call LogDebugString("No instance on " + oClassName, WARNING_LEVEL_DEV)
GetWMIObjectCollection = 0
Exit Function
Else
If (Err.number &lt;&gt; 0) Then
Call LogDebugString("Error on accessing " + oClassName, WARNING_LEVEL_DEV)
Exit Function
Else
GetWMIObjectCollection = 1
End If
End If
End Function

Function QueryWMIObjectCollection(ByVal oNameSpace, ByVal oWQL, ByRef oObjectCollection)

Call LogDebugString("Entering QueryWMIObjectCollection", INFO_LEVEL_FUNCTION)
QueryWMIObjectCollection = -1
Dim e
Set e = New Error
On Error Resume Next

Set oObjectCollection = GetObject("winmgmts:{impersonationLevel=impersonate}//./" &amp; oNameSpace ).ExecQuery(oWQL)

WScript.Echo "oObjectCollection.Count" + CStr(oObjectCollection.Count)
Call LogDebugString("oObjectCollection.Count" + CStr(oObjectCollection.Count), INFO_LEVEL_DETAIL)
'Check WMI communications...
If (oObjectCollection is nothing) Then
Call LogDebugString("No " + oClassName + " class in the namespace", INFO_LEVEL)
Exit Function
End If

If (oObjectCollection.Count = 0) Then 'Try to count system instances...
Call LogDebugString("No instance on " + oClassName, WARNING_LEVEL_DEV)
QueryWMIObjectCollection = 0
Exit Function
Else
If (Err.number &lt;&gt; 0) Then
Call LogDebugString("Error on accessing " + oClassName, WARNING_LEVEL_DEV)
Exit Function
Else
QueryWMIObjectCollection = 1
End If
End If
End Function

Function SCOMCreateObject(ByVal sProgramId)

Dim oError
Set oError = New Error

On Error Resume Next
Set SCOMCreateObject = CreateObject(sProgramId)
oError.Save
On Error Goto 0

If (oError.Number &lt;&gt; 0) Then
Call LogDebugString("Error to create object", ERROR_LEVEL)
WScript.Quit
End If

End Function
Function ChangeString(ByRef sName)
Dim temp
ChangeString = sName
temp = Replace(sName,"{","")
temp = Replace(temp,"}","")
ChangeString = temp
End Function

Function licKeyValidate( byVal sFeatureId )
' Description:
' Validates the OS instance or IMM oriented license key
' of the given feature of the localhost?
' Possible Return Code:
' 1, if valid but about to expire (in 14 days).
' 0, if valid.
' -1, if no license key is installed.
' -2, if the license key was already expired.
' -3, if the license key is invalid (integrity broken).
' -10, if the IMM-oriented license key was recently changed
' and needs to be reprocessed first.

licKeyValidate = CInt(licKeyValidateRegValue())
End Function

'FOR THE DEBUG ONLY
Function licKeyValidateRegValue()

Dim oReg, rcCode, iWinEventFiltering
'Dim iWinEventFiltering, set this value to 1 means turn off this filter. 0, turn on.
iWinEventFiltering = "-1"

Call LogDebugString("Entering licKeyValidateRegValue", INFO_LEVEL+1)

Set oReg = GetObject("winmgmts://localhost/root/default:StdRegProv")
If (not(oReg is nothing)) Then
Dim szValue
rcCode = oReg.GetStringValue(HKEY_LOCAL_MACHINE, WINEVENT_LICENSE_KEY, WINEVENT_LICENSE_NAME, szValue)
If (Not(IsNull(szValue))) Then
iWinEventFiltering = szValue
End If
End If
licKeyValidateRegValue = iWinEventFiltering

End Function

Function GetEndpointLic(ByRef sLicLevel)
'sLicLevel = null
sLicLevel = "None"
'sLicTok = null

'Dim oReg ''' This should already be defined and init'ed globally '''
Dim rcCode,TrialDays,TrialInfo
rcCode = -1

Call LogDebugString("Entering GetEndpointLic", INFO_LEVEL_DETAIL)
TrialInfo= GetEndpointTrialInfo(TrialDays)

''' The registry provider should have already been initialized globally
''' in this script. The LicManager class depends on oReg as a global.
'Set oReg = GetObject("winmgmts://localhost/root/default:StdRegProv")
If (not(oReg is nothing)) Then

'Get the value, refer to "IBM.LicenseServer.Discovery.Provider"
'rcCode = oReg.GetStringValue(HKEY_LOCAL_MACHINE, IBMHWMP_LICENSE_KEY, _
' IBMHWMP_LICENSE_TOKEN_NAME, sLicTok)
'rcCode = oReg.GetStringValue(HKEY_LOCAL_MACHINE, IBMHWMP_LICENSE_KEY, _
' IBMHWMP_LICENSE_LEVEL, sLicLevel)

Dim oLicValidator, aLicLevelERs, oBestLevelER
Set oLicValidator = new LicManager
Call oLicValidator.LoadFromRegistry()
aLicLevelERs = oLicValidator.LevelERs
If IsArray(aLicLevelERs) Then
'sLicTok = oLicValidator.LicenseToken
Call oLicValidator.FindBestFeatLevel(oBestLevelER)
If Not IsNull(oBestLevelER) Then
sLicLevel = oBestLevelER.ToString()
rcCode = 1
Else
Call LogDebugString("The best matched feature level could " + _
"not be obtained on this server", WARNING_LEVEL)
End If
Else
Call LogDebugString("No feature levels activated on this Lenovo License Server", WARNING_LEVEL)
End If
If(TrialInfo=1)Then
If(sLicLevel&lt;&gt;"255.0")Then
sLicLevel="Trial,left "&amp; TrialDays &amp;" days"
rcCode = 1
End If
End If
'If (Not(IsNull(sLicLevel)) And Not(IsEmpty(sLicLevel))) Then
' rcCode = 1
'Else
' sLicLevel = "None"
' rcCode = -1
'End If
'
'If (Not(IsNull(sLicTok)) And Not(IsEmpty(sLicTok))) Then
' rcCode = 1
'Else
' sLicTok = "None"
' rcCode = -1
'End If

End If
GetEndpointLic = rcCode

End Function

'Return:
'1:Yes,trial license available
'-1:No,trial license invalid
'Const IBMHWMP_LICENSE_KEY = "SOFTWARE\IBM\Systems Management Integrations\LicenseEndpoint"
Const IBMHWMP_TRIAL_LICENSE_TOKEN_NAME = "TrialActivation"
Function GetEndpointTrialInfo(ByRef sTrialInfo)

Dim rcCode,sTrialDays
sTrialInfo = "None"

rcCode = -1

Call LogDebugString("Entering GetEndpointTrialInfo", INFO_LEVEL_DETAIL)


set oReg = GetObject( "winmgmts:{impersonationLevel=impersonate}!" &amp; _
"//./root/default:StdRegProv")


call oReg.GetStringValue( HKEY_LOCAL_MACHINE, LenovoHWMP_LICENSE_KEY, IBMHWMP_TRIAL_LICENSE_TOKEN_NAME, sTrialDays )
if IsNull(sTrialDays) Or IsEmpty(sTrialDays) then
call oReg.GetStringValue( HKEY_LOCAL_MACHINE, IBMHWMP_LICENSE_KEY, IBMHWMP_TRIAL_LICENSE_TOKEN_NAME, sTrialDays )
End if

if IsNull(sTrialDays) Or IsEmpty(sTrialDays) then
rcCode=-1
sTrialInfo = "None"
else
rcCode=1
sTrialInfo=sTrialDays
End if

GetEndpointTrialInfo = rcCode

End Function




class LicManager

private m_aLevelERs
public property get LevelERs
LevelERs = m_aLevelERs
end property

private m_sLicToken
public property get LicenseToken
LicenseToken = m_sLicToken
end property

private sub Class_Initialize()
m_aLevelERs = null
m_sLicToken = ""
end sub

public sub LoadFromRegistry()

dim nLevelsLoaded, licenseFlag
nLevelsLoaded = 0
m_aLevelERs = null
m_sLicToken = ""
licenseFlag = 1

dim aKeyEntryNames, aKeyEntryTypes
Call LogDebugString(".. LicManager: loading from registry key '" + _
LenovoHWMP_LICENSE_KEY + "'", INFO_LEVEL_FUNCTION)
Call oReg.EnumValues( HKEY_LOCAL_MACHINE, LenovoHWMP_LICENSE_KEY, _
aKeyEntryNames, aKeyEntryTypes )

if isNull( aKeyEntryNames ) or not(isArray( aKeyEntryNames )) then
Call LogDebugString(".. LicManager: loading from registry key '" + _
IBMHWMP_LICENSE_KEY + "'", INFO_LEVEL_FUNCTION)
Call oReg.EnumValues( HKEY_LOCAL_MACHINE, IBMHWMP_LICENSE_KEY, _
aKeyEntryNames, aKeyEntryTypes )
licenseFlag = 0
end if
if isNull( aKeyEntryNames ) or not(isArray( aKeyEntryNames )) then
exit sub
end if

Call LogDebugString(".. LicManager: # of registry value entries = " + _
CStr(UBound(aKeyEntryNames)+1), INFO_LEVEL_DETAIL)

dim ii
for ii=0 to UBound(aKeyEntryNames)
if 1 = aKeyEntryTypes( ii ) then ' 1 = REG_SZ
if IBMHWMP_LICENSE_TOKEN_NAME = aKeyEntryNames(ii) then
dim sLevelERsEncoded, sLevelERsDecoded, asSplitERs
if licenseFlag = 1 then
call oReg.GetStringValue( HKEY_LOCAL_MACHINE, LenovoHWMP_LICENSE_KEY, _
aKeyEntryNames(ii), sLevelERsEncoded )
else
call oReg.GetStringValue( HKEY_LOCAL_MACHINE, IBMHWMP_LICENSE_KEY, _
aKeyEntryNames(ii), sLevelERsEncoded )
end if
if IsNull(sLevelERsEncoded) Or IsEmpty(sLevelERsEncoded) then
call LogDebugString("!! LicManager: Registry value " + _
aKeyEntryNames(ii) + " null or empty", ERROR_LEVEL)
else
call LogDebugString(".. LicManager: " + aKeyEntryNames(ii) + _
"='" + sLevelERsEncoded + "'", INFO_LEVEL_DETAIL)
m_sLicToken = sLevelERsEncoded
sLevelERsDecoded = fDecode(sLevelERsEncoded)
call LogDebugString(".. LicManager: " + aKeyEntryNames(ii) + _
"='" + sLevelERsDecoded + "' [Decoded]", INFO_LEVEL_DETAIL)
asSplitERs = split(sLevelERsDecoded, vbTab)
if UBound(asSplitERs) &gt;= 0 then
dim jj
for jj=0 to UBound(asSplitERs)
call LogDebugString(".. LicManager: Retrieved '" + _
asSplitERs(jj) + "'", INFO_LEVEL_DETAIL)
dim oLevelER
set oLevelER = new FeatLevelER
if 0 &lt;= oLevelER.ParseLevelER( asSplitERs(jj) ) then
if 0 = nLevelsLoaded then
m_aLevelERs = array( 0 ) ' create a 1-element array of '0'
else
redim preserve m_aLevelERs( nLevelsLoaded )
end if
set m_aLevelERs( nLevelsLoaded ) = oLevelER
nLevelsLoaded = nLevelsLoaded + 1
call LogDebugString("&gt;&gt; LicManager: Parsed " + _
oLevelER.ToString(), INFO_LEVEL)
end if
next
end if
end if
end if
end if
next

end sub ' LoadFromRegistry

public sub FindBestFeatLevel( byRef oBestLevelER )
oBestLevelER = null
if not( isArray( m_aLevelERs ) ) then
exit sub
end if
if UBound(m_aLevelERs) &gt;= 0 then
dim ii, oLevelER
set oBestLevelER = m_aLevelERs(0)
for ii=1 to UBound(m_aLevelERs)
set oLevelER = m_aLevelERs(ii)
if (oLevelER.LevelMajor &gt; oBestLevelER.LevelMajor) Or _
(oLevelER.LevelMajor = oBestLevelER.LevelMajor And _
oLevelER.LevelMinor &gt; oBestLevelER.LevelMinor) then
set oBestLevelER = oLevelER
end if
next
end if
end sub

end class

class FeatLevelER

private m_levelMajor
private m_levelMinor

public property get LevelMajor
LevelMajor = m_levelMajor
end property
public property get LevelMinor
LevelMinor = m_levelMinor
end property

private sub Class_Initialize()
end sub

public function ParseLevelER( byVal sEntryValue )
dim retCode
retCode = 0
on error resume next
dim asSplit
asSplit = split( sEntryValue, "." )
if UBound(asSplit) &lt;&gt; 1 then
call LogDebugString("!! FeatLevelER.ParseLevelER: unexpected number of items in " + _
"feature level record (" + UBound(asSplit) + ")", ERROR_LEVEL)
retCode = -1
else
m_levelMajor = CInt(asSplit(0))
m_levelMinor = CInt(asSplit(1))
call LogDebugString(".. FeatLevelER.ParseLevelER: MajorVersion = " + _
CStr(m_levelMajor) + ", MinorVersion = " + CStr(m_levelMinor), INFO_LEVEL_DETAIL)
end if
on error goto 0
ParseLevelER = retCode
end function

public function ToString()
ToString = CStr(m_levelMajor) + "." + CStr(m_levelMinor)
end function

end class


' N.B. fDecode() is a verbatim copy of the one in HW MP.
' &lt;twoffer&gt; Can this be referenced instead of copied? &lt;/twoffer&gt;
Function fDecode(sStringToDecode)
'This function will decode a Base64 encoded string and returns the decoded string.
Const CharList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Dim iDataLength, sOutputString, iGroupInitialCharacter
sStringToDecode = Replace(Replace(Replace(sStringToDecode, vbCrLf, ""), vbTab, ""), " ", "")
iDataLength = Len(sStringToDecode)
If iDataLength Mod 4 &lt;&gt; 0 Then
fDecode = "Bad string passed to fDecode() function."
Exit Function
End If
For iGroupInitialCharacter = 1 To iDataLength Step 4
Dim iDataByteCount, iCharacterCounter, sCharacter, iData, iGroup, sPreliminaryOutString
iDataByteCount = 3
iGroup = 0
For iCharacterCounter = 0 To 3
sCharacter = Mid(sStringToDecode, iGroupInitialCharacter + iCharacterCounter, 1)
If sCharacter = "=" Then
iDataByteCount = iDataByteCount - 1
iData = 0
Else
iData = InStr(1, CharList, sCharacter, 0) - 1
If iData = -1 Then
fDecode = "Bad string passed to fDecode() function."
Exit Function
End If
End If
iGroup = 64 * iGroup + iData
Next
iGroup = Hex(iGroup)
iGroup = String(6 - Len(iGroup), "0") &amp; iGroup
sPreliminaryOutString = Chr(CByte("&amp;H" &amp; Mid(iGroup, 1, 2))) &amp; Chr(CByte("&amp;H" &amp; Mid(iGroup, 3, 2))) &amp; Chr(CByte("&amp;H" &amp; Mid(iGroup, 5, 2)))
sOutputString = sOutputString &amp; Left(sPreliminaryOutString, iDataByteCount)
Next
fDecode = sOutputString
End Function

Class Error
Private lNumber
Private sSource
Private sDescription
Private sHelpContext
Private sHelpFile
Public Sub Save()
lNumber = Err.number
sSource = Err.Source
sDescription = Err.Description
sHelpContext = Err.HelpContext
sHelpFile = Err.helpfile
End Sub
Public Sub Raise()
Err.Raise lNumber, sSource, sDescription, sHelpFile, sHelpContext
End Sub
Public Sub Clear()
lNumber = 0
sSource = ""
sDescription = ""
sHelpContext = ""
sHelpFile = ""
End Sub
Public Default Property Get Number()
Number = lNumber
End Property
Public Property Get Source()
Source = sSource
End Property
Public Property Get Description()
Description = sDescription
End Property
Public Property Get HelpContext()
HelpContext = sHelpContext
End Property
Public Property Get HelpFile()
HelpFile = sHelpFile
End Property
End Class


</Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Script">
<Node ID="PassThrough"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<TriggerOnly>true</TriggerOnly>
</ProbeActionModuleType>