Lenovo HW PRO Pack Create Event

IBM.HWPRO.CreateEventLog.Action (WriteActionModuleType)

The Lenovo PRO Pack actions to create an event in the event log during Recovery.

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData

Member Modules:

ID Module Type TypeId RunAs 
CreateEventLogEntry WriteAction Microsoft.Windows.ScriptWriteAction Default

Source Code:

<WriteActionModuleType Accessibility="Internal" Batching="false" ID="IBM.HWPRO.CreateEventLog.Action">
<Configuration>
<xsd:element name="VMHostName" type="xsd:string"/>
<xsd:element name="VMMServerName" type="xsd:string"/>
<xsd:element name="EventOriginalId" type="xsd:string"/>
</Configuration>
<OverrideableParameters/>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="CreateEventLogEntry" TypeID="Windows!Microsoft.Windows.ScriptWriteAction">
<ScriptName>LenovoHWPROCreateEventLogEntry.vbs</ScriptName>
<Arguments>LenovoHWPROCreateEventLogEntry.vbs "$Config/VMHostName$" "$Config/VMMServerName$" "$Config/EventOriginalId$"</Arguments>
<ScriptBody><Script>

' Create the event log entry of Application event id 700 for PRO tip recovery.
'
SetLocale("en-us")

Const HKEY_LOCAL_MACHINE = &amp;H80000002
Const HWPRO_KEYPATH = "SOFTWARE\IBM\Systems Management Integrations\IBM HW PRO Pack"
Const HWPRO_KEYPATH_Lenovo = "SOFTWARE\Lenovo\Systems Management Integrations\Lenovo HW PRO Pack"

' Set up global defs for debug logging
Const ERROR_LEVEL = 1
Const WARNING_LEVEL = 2
Const INFO_LEVEL = 4
Dim gDebugLevel, gScriptName
gDebugLevel = InitLogDebugLevel()
gScriptName = WScript.Arguments(0)

' Global variables and script arguments
Set oArgs = WScript.Arguments
Set oAPI = CreateObject( "MOM.ScriptAPI" )

If oArgs.Count &lt; 4 Then
Call LogDebugString( "# of script arguments: " + oArgs.Count + "; too few!!", ERROR_LEVEL )
WScript.quit -1
End If

sVMHostName = oArgs(1)
sVMMServerName = oArgs(2)
sEventOriginalId = oArgs(3)

' [NOTE]
' On using VMMPro for event source: for a PRO tip recovery, the script is running on
' the physical VM host under a designated OpsMgr action account, which may not
' the privilege to create a new event source. Therefore we are stuck with the
' VMMPro for event source. Since the event id selected is arbitrary, there is
' a chance for collision; consequently we take extra precaution to avoid
' misfiring, with a prequalifier prepended in the description.

' Use "||" as separators.
sLogDesc = sVMHostName &amp; " || " &amp; sVMMServerName &amp; " || " &amp; sEventOriginalId
sLogDesc = "Lenovo Hardware PRO Tip Recovery || " &amp; sLogDesc

sCmdLine = "eventcreate /T WARNING /ID 700 /L APPLICATION /SO VMMPro /D """ &amp; sLogDesc &amp; ""
Call LogDebugString( "Implementing PRO tip by... '" &amp; sCmdLine &amp; "'", INFO_LEVEL )

Set WshShell = WScript.CreateObject( "WScript.Shell" )
retCode = WshShell.Run( sCmdLine, 0, true )

'-------------------------- End of Main --------------------------

Function InitLogDebugLevel()

' Debug Log Level Definition
Const DEBUG_ROOT_KEYNAME = "Debug"
Const DEBUG_LEVEL_VALUENAME = "Level"

Dim oReg, rcCode, debugLevel
debugLevel = ERROR_LEVEL - 1
Set oReg = GetObject("winmgmts://localhost/root/default:StdRegProv")
If (Err = 0) Then
Dim sLevelValue
rcCode = oReg.GetStringValue(HKEY_LOCAL_MACHINE, HWPRO_KEYPATH + "\" + DEBUG_ROOT_KEYNAME, _
DEBUG_LEVEL_VALUENAME, sLevelValue)
If (IsNull(sLevelValue)) Then
rcCode = oReg.GetStringValue(HKEY_LOCAL_MACHINE, HWPRO_KEYPATH_Lenovo + "\" + DEBUG_ROOT_KEYNAME, _
DEBUG_LEVEL_VALUENAME, sLevelValue)
End If
If (Err = 0 And Not(IsNull(sLevelValue))) Then
On Error Resume Next
debugLevel = CInt(sLevelValue)
On Error Goto 0
End If
End If

InitLogDebugLevel = debugLevel

End Function

Sub LogDebugString(debugString, debugLevel)

If (Int(gDebugLevel) &gt;= Int(debugLevel)) Then
Dim eventLogLevel
If debugLevel &lt;= ERROR_LEVEL Then
eventLogLevel = ERROR_LEVEL
ElseIf debugLevel &lt;= WARNING_LEVEL Then
eventLogLevel = WARNING_LEVEL
Else
eventLogLevel = INFO_LEVEL
End If
Call oAPI.LogScriptEvent(gScriptName, 700, eventLogLevel, debugString)
End If

End Sub
</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="CreateEventLogEntry"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>