Dim DefaultThresholdWarning, DefaultThresholdCritical, ThresholdWarning, ThresholdCritical, AgentLicense, bPowerThresholdSupported
Dim FirmwareType, DirAgentVersion
Dim errMessage, successMessage, cimVersion, check, powerCimKey
errMessage = ""
check = 0
'Setup logging
debug = -1
Set oReg = GetObject("winmgmts://localhost/root/default:StdRegProv")
Set oAPI = CreateObject("MOM.ScriptAPI")
If (not(oReg is nothing)) Then
RC_Code = oReg.GetStringValue(HKEY_LOCAL_MACHINE, DEBUG_INFO_KEY, DEBUG_LEVEL_NAME, debug)
If ( RC_Code<>0) Then
debug = -1
End If
End If
If (WScript.Arguments.Count < 5) Then
Call LogDebugString("Short of arguments count : " & WScript.Arguments.Count, INFO_LEVEL)
WScript.Quit -1
End If
set oReg = GetObject( "winmgmts:{impersonationLevel=impersonate}!" & _
"//./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
If (not(oReg is nothing)) Then
on error resume next
Dim taskSupported, requiredLicense
taskSupported = "True"
requiredLicVer = "True"
RC_Code = 0
errMessage = ""
Dim errMessage_nonUEFI
errMessage_nonUEFI = "This premium feature is only supported on UEFI based servers. It is not supported on " + FirmwareType + " based servers." & vbcrlf
dim asSplit, levelMajor, levelMinor
Dim rcCode,TrialDays,TrialInfo
asSplit = split( AgentLicense, "." )
TrialInfo= GetEndpointTrialInfo(TrialDays)
If(TrialInfo<>1)Then
if UBound(asSplit) <> 1 then
errMessage = "A valid license level was not detected on this agent system. " + _
"This feature is only available for managed systems with a premium license." + _
"The minimum required license level for this fee based feature is " & CStr(IBMHWMP_MINIMUM_LICENSE_MAJOR) + _
"." & CStr(IBMHWMP_MINIMUM_LICENSE_MINOR) & vbcrlf
requiredLicVer = "False"
else
levelMajor = CInt(asSplit(0))
levelMinor = CInt(asSplit(1))
call LogDebugString("SetPowerThreshold: Major License Version = " + _
CStr(levelMajor) + ", Minor License Version = " + CStr(levelMinor), INFO_LEVEL_DETAIL)
If (levelMajor < IBMHWMP_MINIMUM_LICENSE_MAJOR Or _
(levelMajor = IBMHWMP_MINIMUM_LICENSE_MAJOR And levelMinor < IBMHWMP_MINIMUM_LICENSE_MINOR)) then
errMessage = "The license level on this managed system (" & CStr(AgentLicense) + _
") does not meet the minimum required license level (" & CStr(IBMHWMP_MINIMUM_LICENSE_MAJOR) + _
"." & CStr(IBMHWMP_MINIMUM_LICENSE_MINOR) + ") for this premium feature." & vbcrlf
requiredLicVer = "False"
End If
End If
End If
If requiredLicVer = "False" Then
If Not(FirmwareType = "UEFI") Then
errMessage = "ERROR: " & vbcrlf + errMessage + errMessage_nonUEFI & vbcrlf + _
"Please refer to the Lenovo Hardware Management Pack User's Guide for more information on fee based license levels and managed system requirements."
Else
errMessage = "ERROR: " & vbcrlf + errMessage & vbcrlf + _
"Please refer to the Lenovo Hardware Management Pack User's Guide for more information on fee based license levels."
End If
taskSupported = "False"
End If
'End of checking License Level
on error goto 0
If (taskSupported = "False") Then
Call LogDebugString(errMessage, WARNING_LEVEL_DEV)
Call TaskFailedString(errMessage)
WScript.Quit 0
End If
'Now, it has a good license level
on error resume next
If Not(FirmwareType = "UEFI") Then
errMessage = errMessage_nonUEFI
Else
Dim isValidDirAgent
isValidDirAgent = checkDirectorAgentVersion(DirAgentVersion)
If isValidDirAgent = "False" Then
taskSupported = "False"
Else
RC_Code = oReg.GetStringValue(HKEY_LOCAL_MACHINE, IBMHWMP_POWER_CIM_KEY, "PackageVersion", cimVersion)
If (RC_Code = 0) Then
check = checkCIMversion(cimVersion)
If check = 1 Then
powerCimKey = IBMHWMP_POWER_CIM_KEY
End If
Else
RC_Code = oReg.GetStringValue(HKEY_LOCAL_MACHINE, IBMHWMP_POWER_CIM_KEY_32on64, "PackageVersion", cimVersion)
If (RC_Code = 0) Then
check = checkCIMversion(cimVersion)
If check = 1 Then
powerCimKey = IBMHWMP_POWER_CIM_KEY_32on64
End If
Else
errMessage = errMessage & vbcrlf + "The Lenovo Power CIM Provider was not detected on this system. " + _
" The minimum required Lenovo Power CIM Provider version for this premium is " & CStr(IBMCIM_MINIMUM_VERSION_MAJOR) + _
"." & CStr(IBMCIM_MINIMUM_VERSION_MINOR) + "." & vbcrlf
End If
End If
End If
End If
If (errMessage <> "") Then
taskSupported = "False"
End If
on error goto 0
If (taskSupported = "False") Then
errMessage = "ERROR:" & vbcrlf + errMessage & vbcrlf + _
"Please refer to the Lenovo Hardware Management Pack User's Guide for more information on managed system requirements."
Call LogDebugString(errMessage, WARNING_LEVEL_DEV)
Call TaskFailedString(errMessage)
WScript.Quit 0
End If
on error resume next
Call LogDebugString("New PowerThresholdWarning=" & CStr(ThresholdWarning) + _
", PowerThresholdCritical=" & CStr(ThresholdCritical) + _
", AgentLicense=" & CStr(AgentLicense), INFO_LEVEL)
WScript.Echo("Warning Power Threshold = " & CStr(ThresholdWarning))
WScript.Echo("Critical Power Threshold = " & CStr(ThresholdCritical))
WScript.echo("Agent License Level = " & CStr(AgentLicense))
' Writing Power Threshold Token
RC_Code = 0
If (ThresholdWarning < 0) or (ThresholdCritical < 0) Then
errMessage = "ERROR- Cannot set a negative value for warning or critical power threshold!"
RC_Code = -1
ElseIf (ThresholdWarning > ThresholdCritical) And (ThresholdWarning >0) And (ThresholdCritical > 0) Then
errMessage = "ERROR- Cannot set the warning power threshold greater than the critical power threshold!"
RC_Code = -1
End If
on error goto 0
If Not(RC_Code = 0) Then
Call LogDebugString(errMessage, WARNING_LEVEL_DEV)
Call TaskFailedString(errMessage)
WScript.Quit 0
End If
on error resume next
If IsNull(ThresholdWarning) Or IsEmpty(ThresholdWarning) Or (ThresholdWarning = 0) Then
Dim warningValue, return
return = oReg.GetStringValue(HKEY_LOCAL_MACHINE, powerCimKey, IBMHWMP_POWER_THRESHOLD_WARNING, warningValue)
'Delete registry value to unset the Warning value, and user uses the default value
If Not IsNull(warningValue) Then
RC_Code = oReg.DeleteValue( HKEY_LOCAL_MACHINE, powerCimKey, IBMHWMP_POWER_THRESHOLD_WARNING )
End If
If (0 = RC_Code) Then
successMessage = "Successfully unset the warning power threshold from the Lenovo CIM Provider registry key."
Call LogDebugString(successMessage, INFO_LEVEL)
Else
errMessage = "Failed to delete the registry key: " + powerCimKey + "\" + _
IBMHWMP_POWER_THRESHOLD_WARNING & vbcrlf & _
"Return Code = " & RC_Code
' "Error = " & Err.Number + " - " & Err.Description
QuitWScript(errMessage)
End If
Else
'Create Registry key path
RC_Code = oReg.CreateKey( HKEY_LOCAL_MACHINE, powerCimKey )
If ( 0 = RC_Code ) Then
'Set Warning Power Threshold
RC_Code = oReg.SetStringValue( HKEY_LOCAL_MACHINE, powerCimKey, _
IBMHWMP_POWER_THRESHOLD_WARNING, CStr(ThresholdWarning))
If ( 0 = RC_Code ) Then
successMessage = "Successful to set the new warning power threshold to the CIM Provider registry key."
Call LogDebugString(successMessage, INFO_LEVEL)
Else
errMessage = "Failed to set the new warning power threshold value to the CIM Provider registry key: " & vbcrlf & _
+ powerCimKey + "\" + IBMHWMP_POWER_THRESHOLD_WARNING & vbcrlf & _
"Return Code = " & RC_Code
' "Error = " & Err.Number + " - " & Err.Description
QuitWScript(errMessage)
End If
Else
errMessage = "Failed to create registry key path" + powerCimKey & vbcrlf & _
"Return Code = " & RC_Code
' "Error = " & Err.Number + " - " & Err.Description
QuitWScript(errMessage)
End If
End If
on error goto 0
QuitWScript(errMessage)
on error resume next
If IsNull(ThresholdCritical) Or IsEmpty(ThresholdCritical) Or (ThresholdCritical = 0) Then
Dim criticalValue
return = oReg.GetStringValue(HKEY_LOCAL_MACHINE, powerCimKey, IBMHWMP_POWER_THRESHOLD_CRITICAL, criticalValue)
'Delete registry value to unset the Warning value, and user uses the default value
If Not IsNull(criticalValue) Then
RC_Code = oReg.DeleteValue( HKEY_LOCAL_MACHINE, powerCimKey, + _
IBMHWMP_POWER_THRESHOLD_CRITICAL )
End If
If (0 = RC_Code) Then
successMessage = "Successfully unset the critical power threshold from the Lenovo Power CIM Provider registry key."
Call LogDebugString(successMessage, INFO_LEVEL)
'validate power threshold values
RC_Code = ValidatePowerThresholds(ThresholdWarning, ThresholdCritical)
Else
errMessage = "Failed to delete the registry key: " + powerCimKey + "\" + _
IBMHWMP_POWER_THRESHOLD_CRITICAL & vbcrlf & _
"Return Code = " & RC_Code
' "Error = " & Err.Number + " - " & Err.Description
QuitWScript(errMessage)
End If
Else
'Set Critical Power Threshold
RC_Code = oReg.SetStringValue( HKEY_LOCAL_MACHINE, powerCimKey, +_
IBMHWMP_POWER_THRESHOLD_CRITICAL, CStr(ThresholdCritical))
If ( 0 = RC_Code ) Then
'validate power threshold values
RC_Code = ValidatePowerThresholds(ThresholdWarning, ThresholdCritical)
Else
errMessage = "Failed to set the new critical power threshold value to the Lenovo Power CIM Provider registry key: " & vbcrlf & _
powerCimKey + "\" + IBMHWMP_POWER_THRESHOLD_CRITICAL & vbcrlf & _
"Return Code = " & RC_Code
' "Error = " & Err.Number + " - " & Err.Description
QuitWScript(errMessage)
End If
End If
If (0 = RC_Code) Then
'Final check to make sure thresholds are valid
'check if capping is enabled and thresholds > Pcap
Dim iResult2, oPcappingCollection, oPcappingInstance, oPowerCapValue, oCappingEnabledValue
iResult2 = GetWMIObjectCollection(IBMSD_NAMESPACE, "IBMPSG_PowerCappingInformation", oPcappingCollection)
If (iResult2 > 0) Then
Call LogDebugString("Getting post object from IBMPSG_PowerCappingInformation", INFO_LEVEL_FUNCTION)
For Each oPcappingInstance in oPcappingCollection
oPowerCapValue = oPcappingInstance.PCap
oCappingEnabledValue = oPcappingInstance.CappingEnabled
Next
If ((oCappingEnabledValue = "True") And (CInt(oPowerCapValue) < ThresholdWarning Or CInt(oPowerCapValue) < ThresholdCritical)) Then
successMessage = "WARNING- The power threshold value(s) can never be reached because it is greater than the power cap (" _
& oPowerCapValue + ")."
Call LogDebugString(successMessage, INFO_LEVEL_FUNCTION)
WScript.Echo(successMessage)
ElseIf (oCappingEnabledValue = "False") Then
successMessage = "WARNING- An attempt to access the Lenovo Power CIM power capping information has failed " + _
"during setting up the power threshold values. It is likely that this system does not support power capping due to insufficient firmware levels. " + _
"If this system does meet the power capping requirements defined in the Lenovo Hardware Management Pack User's Guide, " + _
"please verify the integrity of the IBM Director Platform Agent CIM Server."
Call LogDebugString(successMessage, INFO_LEVEL_FUNCTION)
WScript.Echo(successMessage)
End If
'else- iResult2 <= 0)
Else
successMessage = "WARNING- During setting up the power threshold values, an attempt to access the Lenovo Power CIM power capping " + _
"information has failed. It is likely that this system does not support power capping due to insufficient firmware levels. " + _
"If this system does meet the power capping requirements defined in the Lenovo Hardware Management Pack User's Guide, " + _
"please verify the integrity of the IBM Director Platform Agent CIM Server."
Call LogDebugString(successMessage, INFO_LEVEL_FUNCTION)
WScript.Echo(successMessage)
End If
End If
on error goto 0
QuitWScript(errMessage)
End If
'''' END MAIN ''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''
'''' Delare subs and functions below
'Check the version of Director Agent
Function checkDirectorAgentVersion(DirAgentVersion)
dim asSplit, versionMajor, versionMinor, versionBuild
If DirAgentVersion = "Not-installed" Or DirAgentVersion = "" Then
errMessage = errMessage + "The IBM Director Platform Agent was not detected on this system! " + _
"The minimum required IBM Director Agent version for this feature is " & CStr(IBMDIR_AGENT_MINIMUM_VERSION_MAJOR) + _
"." & CStr(IBMDIR_AGENT_MINIMUM_VERSION_MINOR) + "." & CStr(IBMDIR_AGENT_MINIMUM_VERSION_BUILD) + "."
Else
asSplit = split( DirAgentVersion, "." )
If Not(UBound(asSplit) <> 2) Or Not(UBound(asSplit) <> 1) Then
versionMajor = CInt(asSplit(0))
versionMinor = CInt(asSplit(1))
versionBuild = 0
If (UBound(asSplit) <> 1) Then
versionBuild = CInt(asSplit(2))
End If
call LogDebugString("Major Director Agent Version = " + CStr(versionMajor) + _
", Minor Director Agent Version = " + CStr(versionMinor) + _
", Build Director Agent Version = " + CStr(versionBuild), INFO_LEVEL_DETAIL)
If (versionMajor < IBMDIR_AGENT_MINIMUM_VERSION_MAJOR Or _
(versionMajor = IBMDIR_AGENT_MINIMUM_VERSION_MAJOR And versionMinor < IBMDIR_AGENT_MINIMUM_VERSION_MINOR) Or _
(versionMajor = IBMDIR_AGENT_MINIMUM_VERSION_MAJOR And versionMinor = IBMDIR_AGENT_MINIMUM_VERSION_MINOR And _
versionBuild < IBMDIR_AGENT_MINIMUM_VERSION_BUILD)) Then
errMessage = errMessage + "The IBM Director Agent version on this managed system (" & CStr(DirAgentVersion) + _
") does not meet the minimum required IBM Director Agent version (" & CStr(IBMDIR_AGENT_MINIMUM_VERSION_MAJOR) + _
"." & CStr(IBMDIR_AGENT_MINIMUM_VERSION_MINOR) + "." & CStr(IBMDIR_AGENT_MINIMUM_VERSION_BUILD)+ ") for this premium feature." & vbcrlf
End if
Else
errMessage = errMessage + "An invalid version of the IBM Director Agent (" + DirAgentVersion + ") was detected on this managed system." + _
"The minimum required IBM Director Agent version for this feature is " & CStr(IBMDIR_AGENT_MINIMUM_VERSION_MAJOR) + _
"." & CStr(IBMDIR_AGENT_MINIMUM_VERSION_MINOR) + "." & CStr(IBMDIR_AGENT_MINIMUM_VERSION_BUILD) + "."
End if
End If
If errMessage <> "" Then
checkDirectorAgentVersion = "False"
Else
checkDirectorAgentVersion = "True"
End If
End Function
'Check the version of Power CIM to run the task
Function checkCIMversion(CIMVersion)
dim asSplit, versionMajor, versionMinor
asSplit = split( CIMVersion, "." )
if UBound(asSplit) <> 2 then
errMessage = errMessage & vbcrlf + "An invalid version of the Lenovo Power CIM Provider (" + CIMVersion + ") was detected on this agent system. " + _
"The minimum required Lenovo Power CIM Provider version for this premium is " & CStr(IBMCIM_MINIMUM_VERSION_MAJOR) + _
"." & CStr(IBMCIM_MINIMUM_VERSION_MINOR) + "." & vbcrlf
else
versionMajor = CInt(asSplit(0))
versionMinor = CInt(asSplit(1))
call LogDebugString("Major CIM Provider Version = " + CStr(versionMajor) + _
", Minor CIM Provider Version = " + CStr(versionMinor), INFO_LEVEL_DETAIL)
if (versionMajor < IBMCIM_MINIMUM_VERSION_MAJOR Or _
(versionMajor = IBMCIM_MINIMUM_VERSION_MAJOR And versionMinor < IBMCIM_MINIMUM_VERSION_MINOR)) then
errMessage = errMessage & vbcrlf + "The Lenovo Power CIM Provider version on this managed system (" & CStr(CIMVersion) + _
") does not meet the minimum required Lenovo Power CIM Provider version (" & CStr(IBMCIM_MINIMUM_VERSION_MAJOR) + _
"." & CStr(IBMCIM_MINIMUM_VERSION_MINOR) + ") for this premium feature." & vbcrlf
end if
end if
If errMessage <> "" Then
checkCIMversion = 0
Else
checkCIMversion = 1
End If
End Function
' Get WMI Object Collection
Function GetWMIObjectCollection(ByVal oNameSpace, ByVal oClassName, ByRef oObjectCollection)
Call LogDebugString("Entering GetWMIObjectCollection(" + oNameSpace + ":" + oClassName + ")", INFO_LEVEL_FUNCTION)
GetWMIObjectCollection = -1
Dim e
Set e = New Error
On Error Resume Next
Set oObjectCollection = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _
"." & "/" & oNameSpace & ":" & oClassName).Instances_
'Check WMI communications...
If (oObjectCollection is nothing) Then
Call LogDebugString("No " + oClassName + " class in the namespace", INFO_LEVEL_DETAIL)
Exit Function
End If
If (oObjectCollection.Count = 0) Then 'Try to count system instances...
Call LogDebugString("No instance on " + oClassName, INFO_LEVEL_DETAIL)
GetWMIObjectCollection = 0
Exit Function
Else
If (Err.number <> 0) Then
Call LogDebugString("Error on accessing " + oClassName, ERROR_LEVEL)
Exit Function
Else
GetWMIObjectCollection = 1
End If
End If
End Function
' Debug event logging
Sub LogDebugString(debugString, debugLevel)
If (Int(debug) >= Int(debugLevel)) Then
Call oAPI.LogScriptEvent("SetPowerThreshold.vbs", 401, DebugLevelToLogLevel(debugLevel), debugString)
End If
End Sub
Function DebugLevelToLogLevel(debugLevel)
DebugLevelToLogLevel = 4
If debugLevel <= 1 then
DebugLevelToLogLevel = 1
ElseIF debugLevel <= 3 then
DebugLevelToLogLevel = 2
Else
DebugLevelToLogLevel = 4
End If
End Function
'Script Echo
Sub TaskFailedString(errMessage)
WScript.Echo( "----------------------------------------" & vbcrlf & _
"-------------- Task failed -------------" & vbcrlf & _
"----------------------------------------" & vbcrlf & _
errMessage & vbcrlf & _
"----------------------------------------" )
End Sub
'Display error messages and quit the script
Sub QuitWScript(errMessage)
If (errMessage <> "") Then
Call LogDebugString(errMessage, WARNING_LEVEL_DEV)
Call TaskFailedString(errMessage)
WScript.Quit 0
End If
End Sub
'Validate post power threshold values
Function ValidatePowerThresholds(ByRef ThresholdWarning, ByRef ThresholdCritical)
Dim iResult, oPthresholdCollection, oPthresholdInstance, oPostThresholdWarningValue, oPostThresholdCriticalValue
Dim count, resetBothThresholds, resetOnlyWarning, resetOnlyCritical, done, RC_Code
count = 0
done = "False"
resetBothThresholds = "False"
resetOnlyWarning = "False"
resetOnlyCritical = "False"
RC_Code = 0
'run few times to check if the values of power thresholds got updated
Do While (count < 6 and done = "False")
count = count + 1
iResult = GetWMIObjectCollection(IBMSD_NAMESPACE, "IBMPSG_AveragePowerUsageSensor", oPthresholdCollection)
If (iResult > 0) Then
Call LogDebugString("Getting post object from IBMPSG_AveragePowerUsageSensor", INFO_LEVEL_FUNCTION)
For Each oPthresholdInstance in oPthresholdCollection
oPostThresholdWarningValue = oPthresholdInstance.LowerThresholdNonCritical
oPostThresholdCriticalValue = oPthresholdInstance.LowerThresholdCritical
Next
'sleep in miliseconds
WScript.sleep(10*1000)
If (ThresholdWarning = 0) And (ThresholdCritical = 0) Then
resetBothThresholds = "True"
ElseIf ThresholdWarning = 0 Then
resetOnlyWarning = "True"
ElseIf ThresholdCritical = 0 Then
resetOnlyCritical = "True"
End If
'Get default values
If (ThresholdWarning = 0) Then
ThresholdWarning = oPostThresholdWarningValue
Call LogDebugString("Successfully unset the Warning Power Threshold to its default value (" + _
ThresholdWarning + ").", INFO_LEVEL_FUNCTION)
End If
If (ThresholdCritical = 0) Then
ThresholdCritical = oPostThresholdCriticalValue
Call LogDebugString("Successfully unset the Critical Power Threshold to its default value (" + _
ThresholdCritical + ").", INFO_LEVEL_FUNCTION)
End If
If (resetBothThresholds = "True") Then
done = "True"
ElseIf (resetOnlyWarning = "True") And (CStr(oPostThresholdCriticalValue)= CStr(ThresholdCritical)) Then
done = "True"
ElseIf (resetOnlyCritical = "True") And (CStr(oPostThresholdWarningValue)= CStr(ThresholdWarning)) Then
done = "True"
ElseIf ((CStr(oPostThresholdWarningValue)= CStr(ThresholdWarning)) And (CStr(oPostThresholdCriticalValue)= CStr(ThresholdCritical))) Then
done = "True"
ElseIf (count =6) Then
RC_Code = -1
If ((CStr(oPostThresholdWarningValue) <> CStr(ThresholdWarning)) And (CStr(oPostThresholdCriticalValue) <> CStr(ThresholdCritical))) Then
errMessage = "ERROR- Timed out! Failed to set the new warning and critical power thresholds. There might be a firmware error!"
ElseIf (CStr(oPostThresholdWarningValue) <> CStr(ThresholdWarning)) Then
errMessage = "ERROR- Timed out! Failed to set the new warning power threshold. There might be a firmware error!"
ElseIf (CStr(oPostThresholdCriticalValue) <> CStr(ThresholdCritical)) Then
errMessage = "ERROR- Timed out! Failed to set the new critical power threshold. There might be a firmware error!"
End If
done = "True"
End If
Else
RC_Code = -1
done = "True"
errMessage = "ERROR: An attempt to access the Lenovo Power CIM Provider power usage information has failed. " + _
"Please check the integrity of the IBM Director Platform Agent CIM Server. " + _
"It is likely that the Lenovo Power CIM Provider is not working properly. Refer to the troubleshooting " + _
"section in the Lenovo Hardware Management Pack User's Guide for more Power CIM information."
End If
QuitWScript(errMessage)
Loop
If (RC_Code = 0) Then
If (ThresholdWarning > ThresholdCritical) Then
ValidatePowerThresholds = -1
If resetOnlyWarning = "True" Then
errMessage = "ERROR- Cannot set the Critical Power Threshold (" + CStr(ThresholdCritical) + _
") less than the default Warning Power Threshold (" + CStr(ThresholdWarning) + ")."
ElseIf resetOnlyCritical = "True" Then
errMessage = "ERROR- Cannot set the Warning Power Threshold (" + CStr(ThresholdWarning) + _
") greater than the default Critical Power Threshold (" + CStr(ThresholdCritical) + ")."
Else
errMessage = "ERROR- Cannot set the Warning Power Threshold greater than the Critical Power Threshold."
End If
Else
ValidatePowerThresholds = 0
Call LogDebugString("PowerThresholdWarning=" & oPostThresholdWarningValue & + _
" and PowerThresholdCritical=" & oPostThresholdCriticalValue, INFO_LEVEL_FUNCTION)
successMessage = "Successful to set the new power thresholds"
Wscript.echo(successMessage)
Call LogDebugString(successMessage, INFO_LEVEL)
End If
Else
ValidatePowerThresholds = -1
End If
End Function
'Class Error
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