Dell Server Component Discovery Module

Dell.WindowsServer.HWComponentDiscovery (DataSourceModuleType)

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval SecondsInterval in Seconds for the Discovery Cycle
LogLevelint$Config/LogLevel$Log LevelLog Level

Source Code:

<DataSourceModuleType ID="Dell.WindowsServer.HWComponentDiscovery" Accessibility="Internal">
<Configuration>
<xsd:element name="ServerType" type="xsd:string"/>
<xsd:element name="IntervalSeconds" type="xsd:integer"/>
<xsd:element name="Computer" type="xsd:string"/>
<xsd:element name="LogLevel" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" ParameterType="int" Selector="$Config/IntervalSeconds$"/>
<OverrideableParameter ID="LogLevel" ParameterType="int" Selector="$Config/LogLevel$"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>DellServerHWComponentDiscovery.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Config/Computer$ $Config/LogLevel$ $Target/Property[Type="Dell.WindowsServer.Server"]/OMSAVersion$ $Config/ServerType$</Arguments>
<ScriptBody><Script>
'**********************************************************************************
' Script Name - Dell Server HW Component Discovery
' Author: Vignesh Pandian, Muralidhar L
'
' Description:
' Discover all hardware components for a Dell server with instrumentation using CIM
'
' (c) Copyright Dell Inc. 2007-2015. All rights reserved
'**********************************************************************************

'*********************************
' MAIN begin
'*********************************

Option Explicit
On Error Resume Next
SetLocale("en-us")
Dim oArgs
Set oArgs = WScript.Arguments
If oArgs.Count &lt; 6 Then
Wscript.Quit -1
End If

Dim sourceId, managedEntityId, targetComputer, varOMSAVersion
Dim memFlag, procFlag, storageFlag, sensorsFlag, psFlag, lccFlag, varCardDeviceStorageSize
Dim logLevel, objLogTextFile, objLogFSO, logMessage, serverType

sourceId = oArgs(0)
managedEntityId = oArgs(1)
targetComputer = oArgs(2)
logLevel = oArgs(3)
varOMSAVersion = oArgs(4)
serverType = oArgs(5)

' Create/Open a log file for writing error logs
If logLevel &lt;&gt; 0 Then
Dim fileSize, strOutFile
Const strFileName = "DellServerHWComponent.log"
Const ForAppending = 8
Const ForWriting = 2
Const MaxFileSize = 524288 'File Size is limited to 512 KB

dim wsShell : Set wsShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wsShell.Environment
dim tFolder : tFolder = wshSysEnv("TEMP")
dim wshPrcEnv : Set wshPrcEnv = wsShell.Environment("Process")
tFolder = Replace(tFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)

Set objLogFSO = CreateObject("Scripting.FileSystemObject")
If Not objLogFSO.FolderExists(tFolder) Then
objLogFSO.CreateFolder(tFolder)
End If
strOutFile = tFolder &amp;"\"&amp; strFileName
If Not objLogFSO.FileExists(strOutFile) Then
Set objLogTextFile = objLogFSO.CreateTextFile(strOutFile)
objLogTextFile.Close
End If
fileSize = objLogFSO.GetFile(strOutFile).Size
If (fileSize &gt; MaxFileSize) Then
Set objLogTextFile = objLogFSO.OpentextFile(strOutFile, ForWriting, True)
Else
Set objLogTextFile = objLogFSO.OpentextFile(strOutFile, ForAppending, True)
End If
logMessage = Now &amp; " DEBUG: Script - Dell Server HardwareComponent Discovery : Start()"
MOMDebugLog 1, logMessage
Err.Clear
End If

memFlag = 0
procFlag = 0
storageFlag = 0
sensorsFlag = 0
psFlag = 0
lccFlag = 0
varCardDeviceStorageSize=""

Dim oAPI, oDiscoveryData, oInst, strComputer, objDellConnection
Set oAPI = CreateObject("MOM.ScriptAPI")

set oDiscoveryData = oAPI.CreateDiscoveryData(0, sourceId, managedEntityId)
strComputer = "."

Const DEF_OMSA_BIN_PATH = "C:\Program Files\Dell\OpenManage\oma\bin"
Const OMSA_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Dell Computer Corporation\Dell OMA\InstallPath"
Const OMSA64_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Dell Computer Corporation\Dell OMA\InstallPath"
Const BASE_OMSA_VERSION_IDRAC_DISCOVERY = "6.3"
Const FIRMWARE_VERSION_IDRAC_DISCOVERY = "1.54"

set objDellConnection = GetObject("winmgmts:" &amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\root\cimv2\Dell")
If IsEmpty(objDellConnection) Or (Err.Number &lt;&gt; 0) Then
logMessage = "Unable to open WMI Namespace root-cimv2-dell. Check to see if the WMI service is enabled and running, and Install/Re-Install ServerAdministrator to ensure this WMI namespace exists. " &amp; Err
MOMDebugLog 1, logMessage
Else
DiscoverProc procFlag
DiscoverMem memFlag
DiscoverPS psFlag
MOMDebugLog 1, "Calling DiscoverStorage()"
DiscoverStorage()
DiscoverLCC()
End If

If procFlag = 1 Then
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.Processors']$")
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", targetComputer)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", targetComputer)
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Processors")
call oDiscoveryData.AddInstance(oInst)
End If

If memFlag = 1 Then
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.Memory']$")
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", targetComputer)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", targetComputer)
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Memory")
call oDiscoveryData.AddInstance(oInst)
End If

If psFlag = 1 Then
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.PowerSupply']$")
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", targetComputer)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", targetComputer)
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Power Supply")
call oDiscoveryData.AddInstance(oInst)
End If

MOMDebugLog 1, "adding the storage component"
If storageFlag = 1 Then
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.Storage']$")
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", targetComputer)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", targetComputer)
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Storage")
call oDiscoveryData.AddInstance(oInst)
End If
MOMDebugLog 1, "finished adding the storage component"

set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.Sensors']$")
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", targetComputer)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", targetComputer)
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Sensors")
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.Sensors']/ServerType$", serverType)
call oDiscoveryData.AddInstance(oInst)

Dim variDRACFirmwareVersion
GetiDRACFirmwareVersion variDRACFirmwareVersion

' For LCCStorageCycle
If lccFlag = 1 Then
If ((varOMSAVersion &gt;= BASE_OMSA_VERSION_IDRAC_DISCOVERY)) Then
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.LifeCycleController']$")
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", targetComputer)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", targetComputer)
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "iDRAC")
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.LifeCycleController']/CardDeviceStorageSize$", varCardDeviceStorageSize)
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.LifeCycleController']/FirmwareVersion$", variDRACFirmwareVersion)
call oDiscoveryData.AddInstance(oInst)
End If
End If
' For LCCStorageCycle

' Submit the data
Call oAPI.Return(oDiscoveryData)

logMessage = Now &amp; " DEBUG: Script - Dell Server HardwareComponent Discovery : End()"
MOMDebugLog 1, logMessage

Set oDiscoveryData = Nothing
Set oAPI = Nothing
Set objDellConnection = Nothing

' Close file used for logs
If logLevel &lt;&gt; 0 Then
objLogTextFile.Close
Set objLogTextFile = Nothing
Set objLogFSO = Nothing
End If

' **********************************************
' End Main
' **********************************************

'*****************************************************************
'GetiDRACFirmwareVersion
'Routine to determine current iDRAC Firmware version
'*****************************************************************
Public Function GetiDRACFirmwareVersion (ByRef variDRACFirmwareVersion)
On Error Resume Next
Dim WbemServices, wbemObjectSet, logMessage
Dim strComputer: strComputer = "."
Const IDRAC_STRING = "DRAC"

Set WbemServices = GetObject("winmgmts:" &amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\root\cimv2\dell")
If (WbemServices is Nothing) Or (IsEmpty(WbemServices)) Or (Err.Number &lt;&gt; 0) Then
logMessage = " ERROR: Unable to open WMI Namespace root-cimv2. Check to see if the WMI service is enabled and running, and ensure this WMI namespace exists." &amp; Err.Description
MOMDebugLog 1, logMessage
Err.Clear
else
Set wbemObjectSet = GetObjectSet(wbemServices, "Select * from Dell_Firmware", "Version", "Dell_Firmware")
If Err.Number &lt;&gt; 0 Then
logMessage = " ERROR: Unable to retrieve Dell_Firmware . Err Number:" &amp; Err.Number &amp; "Description:" &amp; Err.Description
MOMDebugLog 1, logMessage
Err.Clear
End If
If wbemObjectSet is Nothing Then
logMessage = "INFO: Unable to retrieve Dell_Firmware Attributes"
MOMDebugLog 1, logMessage
Err.Clear
Else
logMessage = "INFO: Dell_Firmware attributes retrieved successfully"
MOMDebugLog 1, logMessage
Dim objItem
For Each objItem in wbemObjectSet
'Error checking
If Err.Number &lt;&gt; 0 Then
logMessage = " ERROR: Object loop retrieval error. ErrNumber:" &amp; Err.Number &amp; "Description:" &amp; Err.Description
MOMDebugLog 1, logMessage
Err.Clear
End If
'Object Retrieval
If not objItem is nothing Then
If (InStr(objItem.Name,IDRAC_STRING) &lt;&gt; 0) Then
variDRACFirmwareVersion = objItem.Version
End If
End If
Next
logMessage = " iDRAC Firmware Version : " &amp; variDRACFirmwareVersion
MOMDebugLog 1, logMessage
End If
End If
Set wbemObjectSet = Nothing
Set WbemServices = nothing
End Function

'*************************************************************************
' Function : DiscoverMem()
' Desc : To return flag whether to create Memory Group for HardwareComponentDiscovery
' Arguments : memFlag byreference
'*************************************************************************
Function DiscoverMem(ByRef memFlag)
On Error Resume Next
Dim sQuery, colItems, objItemMem, count1

sQuery = "Select * from CIM_PhysicalMemory"

Set colItems = GetObjectSet(objDellConnection, sQuery, "Name", "CIM_PhysicalMemory")
If Err.Number &lt;&gt; 0 Then
logMessage = sQuery &amp; " Error Number:" &amp; Err.Number &amp; "Description:" &amp; Err.Description
MOMDebugLog 1, logMessage
If Err.Number = -2147023169 Then
logMessage = "RPC Failure occurred for namespace root-cimv2-dell"
MOMDebugLog 1, logMessage
End If
Err.Clear
End If
If (colItems is Nothing) or (IsNull(colItems)) Then
logMessage = "Unable to retrieve Mem Unit"
MOMDebugLog 1, logMessage
Err.Clear
Else
logMessage = "Mem Unit query retrieved successfully"

count1 = colItems.count
If count1 &gt; 0 Then
memFlag = 1
End If
End If

Set colItems = Nothing
End Function

'*************************************************************************
' Function : DiscoverLCC()
' Desc : To determine the existence of iDRAC6
' Arguments : None
'*************************************************************************
Public Function DiscoverLCC ()
'Checking the existence of iDRAC6
On Error Resume Next
Dim sQuery, colItems, objItem, device, count1
ExecRacCmd ""
if lccFlag = 1 Then
varCardDeviceStorageSize = "Not Available"
End If

sQuery = "Select * from DELL_ManagedSystemServicesDevice"

Set colItems = GetObjectSet(objDellConnection, sQuery, "deviceSize", "DELL_ManagedSystemServicesDevice")
If Err.Number &lt;&gt; 0 Then
logMessage = " ERROR: Unable to retrieve DELL_ManagedSystemServicesDevice for LCC. Err Number:" &amp; Err.Number &amp; "Description:" &amp; Err.Description
MOMDebugLog 1, logMessage
Err.Clear
End If
If (colItems is Nothing) or (IsNull(colItems)) Then
logMessage = " ERROR: Unable to retrieve DELL_ManagedSystemServicesDevice for LCC"
MOMDebugLog 1, logMessage
Err.Clear
Else
logMessage = "INFO: DELL_ManagedSystemServicesDevice for LCC retrieved successfully"
MOMDebugLog 1, logMessage
count1 = colItems.count

If count1 &gt; 0 Then
lccFlag = 1

'Object Retrieval
For Each objItem in colItems
If not objItem is nothing Then
varCardDeviceStorageSize = objItem.deviceSize
device = objItem.deviceType

If device = 0 Then
varCardDeviceStorageSize = varCardDeviceStorageSize &amp; " MB (Base managed device)"
ElseIf device = 1 Then
varCardDeviceStorageSize = varCardDeviceStorageSize &amp; " MB (Optional managed device)"
End if
End If
Next

logMessage = "INFO: CardStoragesize : " &amp; varCardDeviceStorageSize
MOMDebugLog 1, logMessage

logMessage = "INFO: iDRAC exists"
End If

MOMDebugLog 1, logMessage
End If
End Function

'*************************************************************************
' Function : DiscoverPS()
' Desc : To return flag whether to create PowerSupplyGroup for HardwareComponentDiscovery
' Arguments : psFlag byreference
'*************************************************************************
Function DiscoverPS(ByRef psFlag)
'Retrieving PS Units
On Error resume next
Dim sQuery, colItems, objItemPS, count1

sQuery = "Select * from CIM_PowerSupply"

Set colItems = GetObjectSet(objDellConnection, sQuery, "Name", "CIM_PowerSupply")
If Err.Number &lt;&gt; 0 Then
logMessage = sQuery &amp; " Error Number:" &amp; Err.Number &amp; "Description:" &amp; Err.Description
MOMDebugLog 1, logMessage
If Err.Number = -2147023169 Then
logMessage = "RPC Failure occurred for namespace root-cimv2-dell"
MOMDebugLog 1, logMessage
End If
Err.Clear
End If

If (colItems is Nothing) or (IsNull(colItems)) Then
logMessage = "Unable to retrieve PS Unit"
MOMDebugLog 1, logMessage
Err.Clear
Else
logMessage = "PS Unit query retrieved successfully"

count1 = colItems.count
If count1 &gt; 0 Then
psFlag = 1
End If
End If

Set colItems = Nothing
End Function

'*************************************************************************
' Function : DiscoverProc()
' Desc : To return flag whether to create ProcessorGroup for HardwareComponentDiscovery
' Arguments : procFlag byreference
'*************************************************************************
Function DiscoverProc(ByRef procFlag)
On Error resume next
Dim sQuery, colItems, objItemProc, procCheck

sQuery = "Select * from CIM_Processor"

Set colItems = GetObjectSet(objDellConnection, sQuery, "Name", "CIM_Processor")
If Err.Number &lt;&gt; 0 Then
logMessage = sQuery &amp; " Error Number:" &amp; Err.Number &amp; "Description:" &amp; Err.Description
MOMDebugLog 1, logMessage
If Err.Number = -2147023169 Then
logMessage = "RPC Failure occurred for namespace root-cimv2-dell"
MOMDebugLog 1, logMessage
End If
Err.Clear
End If

If (colItems is Nothing) or (IsNull(colItems)) Then
logMessage = "Unable to retrieve Proc Unit"
MOMDebugLog 1, logMessage
Err.Clear
Else
logMessage = "Proc Unit query retrieved successfully"

For Each objItemProc in colItems
'Error checking
If Err.Number &lt;&gt; 0 Then
logMessage = "Number:" &amp; Err.Number &amp; "Description:" &amp; Err.Description
MOMDebugLog 1, logMessage
Err.Clear
End If

'Object Retrieval
If not objItemProc is nothing Then
procCheck = objItemProc.Status
If Not IsNull(procCheck) Then 'CR194360 Required for Empty slot Processor check
procFlag = 1
Exit Function
End If
End If
Next
End If

Set colItems = Nothing
End Function

'*************************************************************************
' Function : DiscoverStorage()
' Desc : To return flag whether to create StorageGroup for HardwareComponentDiscovery
' Arguments : memFlag byreference
'*************************************************************************
Function DiscoverStorage()
On Error Resume Next
Dim OMSABinPath ' Store Path from Registry key
Dim drive ' Drive letter
Dim version, regError, rc
regError = 0
MOMDebugLog 1, "Entered DiscoverStorage()"
' Get OMSA Lib Path
rc = GetOMABinPath(OMSABinPath, regError)
If rc &lt;&gt; 0 Then
logMessage = "GetOMSAHealth:GetOMABinPath Error"
MOMDebugLog 1, logMessage
Err.Clear
WScript.Quit()
End If

' Get Install root path
rc = GetOMInstallRoot(drive, OMSABinPath) ' return the current absolute path or the root path for the OMSA Install
If rc &lt;&gt; 0 Then
logMessage = "GetOMSAHealth:GetOMInstallRoot Error"
MOMDebugLog 1, logMessage
Err.Clear
WScript.Quit()
End If
If regError = 1 Then
logMessage = "Task Fail: OMSA not installed / OMSA Registry Value not found."
MOMDebugLog 1, logMessage
Err.Clear
WScript.Quit()
End If

' Check VBScript engine version
version = CheckVBScriptEngine()
If version = True OR version = False Then
MOMDebugLog 1, "Calling RunCLI()"
RunCLI drive, OMSABinPath
Else
logMessage = "Error: VBScript corrupted/absent. Please Re-Install Windows Script 5.6 on the Agent"
MOMDebugLog 1, logMessage
Err.Clear
WScript.Quit()
End If
MOMDebugLog 1, "Exiting DiscoverStorage()"
End Function

'*****************************************************************
'Function RunCLI
'Routine For CLI VB.Run (For Version &lt; 5.6)
'*****************************************************************
Function RunCLI(ByVal targetDrive, ByVal strOMSABinPath)
On Error Resume Next
Dim guid1,guid3, wintemp_path
GetTempFolderPath wintemp_path, targetDrive
GetOMReportFileGUID guid1
MOMDebugLog 1, "Calling RunStorageCLI()"
RunStorageCLI targetDrive, strOMSABinPath
End Function

'*****************************************************************
'GetOMABinPath
'Routine to read the registry to query the OMA Install Path
'*****************************************************************
Function GetOMABinPath(o_sPath, ByRef regError)
On Error Resume Next
Dim strOMAKey
Dim oShell, tmp

Set oShell = CreateObject ("WScript.Shell")
o_sPath = ""
On Error Resume Next
o_sPath = oShell.RegRead(OMSA_REG_INTALL_PATH)
If o_sPath = "" Then
o_sPath = oShell.RegRead(OMSA64_REG_INTALL_PATH)
End If
If o_sPath = "" Then
tmp = DEF_OMSA_BIN_PATH &amp; "\omreport.exe"
If(bFileExists(tmp)) Then
o_sPath = DEF_OMSA_BIN_PATH
logMessage = "GetOMABinPath - OMSABinPath is empty, Using Default Existing Path" &amp; DEF_OMSA_BIN_PATH
MOMDebugLog 1, logMessage
Else
regError = 1
End If
Else
o_sPath = o_sPath &amp; "\bin"
End If

If Err &lt;&gt; 0 Then
GetOMSABinPath = Err.Number
Err.Clear
End If
End Function

'*****************************************************************
'GetOMInstallRoot
'Routine to determine the Drive letter where OMSA is installed
'*****************************************************************
Private Function GetOMInstallRoot(ByRef path, ByVal OMSAInstallPath)
On Error Resume Next
' Return the root drive of the OMInstall Path
path = Left(OMSAInstallPath, 2)
End Function

'*****************************************************************
'bFileExists
'Routine to determine if the OMSA Report file is created
'*****************************************************************
Function bFileExists(ByVal filespec1)
On Error Resume Next
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
bFileExists = (fso.FileExists(filespec1))
Set fso = Nothing
End Function

'*****************************************************************
'DelFile
'Routine to delete the OMSA Report file
'*****************************************************************
Function DelFile(ByVal filespec2)
On Error Resume Next
Dim fso, oFile
If bFileExists(filespec2) Then
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile filespec2, True
Set fso = Nothing
End If
If Err &lt;&gt; 0 Then
DelFile = Err.Number
Err.Clear
End If
End Function

'**********************************************************
' CheckVBScriptEngine()
' Check VBScript engine version:
'**********************************************************
Function CheckVBScriptEngine()
On Error Resume Next
Dim bIsCompatV, var
Const VBSCRIPT_MIN_VERSION = 56
var = ((ScriptEngineMajorVersion * 10) + ScriptEngineMinorVersion)
If ((var) &lt; VBSCRIPT_MIN_VERSION) Then
bIsCompatV = False
Else
bIsCompatV = True
End If
If Err &lt;&gt; 0 Then
CheckVBScriptEngine = Err.Number
Err.Clear
Else
CheckVBScriptEngine = bIsCompatV
End If
End Function

'*****************************************************************
'Function RunStorageCLI - Called from RunCLI If StorageArrayManagerFlag = 0
'Routine For VB.Run (For Version &lt; 5.6)
'*****************************************************************
Function RunStorageCLI (ByVal Drive2, ByVal OMSABinPath)
On Error Resume Next
Dim guid22, timer, filespec, rc, oShell, strCommand, strRepFilePath, wintemp_path
Const TIMEOUT = 20
Const OM_REPORT_STORAGE_CONTR = "Storage"

MOMDebugLog 1, "Calling RunStorageCLI():"

GetTempFolderPath wintemp_path, Drive2
GetOMReportFileGUID guid22
strRepFilePath = wintemp_path &amp; "\" &amp; OM_REPORT_STORAGE_CONTR &amp; guid22 &amp; ".xml"
strCommand = "cmd /C " &amp; chr(34) &amp; OMSABinPath &amp; "\" &amp; "omreport.exe" &amp; Chr(34) &amp; " storage controller -fmt xml -outc " &amp; strRepFilePath
filespec = strRepFilePath
Set oShell = CreateObject ("WScript.Shell")
rc = oShell.run (strCommand,0,true)
If rc &lt;&gt; 0 Then
DelFile(strRepFilePath)
Err.Clear
Else
' Infinite Loop Until file OM_REPORT_FILE_NAME is created
timer = 0
Do While bFileExists(filespec) &lt;&gt; -1
WScript.Sleep(1000)
timer = timer + 1
if (timer &gt; TIMEOUT) Then
MOMDebugLog 1, "Exit RunCmd. Reason: OMREPORT STORAGE not responding"
Exit Do
End If
Loop
' Parse XML File
MOMDebugLog 1, "Calling ParseStorageXML():"
ParseStorageXML filespec

' Clean up the CLI Output : Delete OM_REPORT_FILE_NAME for STORAGE
DelFile(strRepFilePath)
End If ' End of If Condition for rc&lt;&gt;0 for oshell.run(omreport storage controller)
Set strRepFilePath = Nothing
Set strCommand = Nothing
Set oShell = Nothing
Set filespec = Nothing
End Function


'*************************************************************************
' Function : ExecRacCmd()
' Desc : To determine RAC Url for DRAC hardware
' Arguments : pass ByReference RACURL string
'*************************************************************************
Function ExecRacCmd (racCmd)
On Error Resume Next
Dim strLaunchRACURL, racAgentExist, strAlertDesc
Dim version, rc, rac
Dim logMessage, Message, RacExitFlag
racAgentExist = 0
RacExitFlag = 0
Dim version1

version1 = CheckVBScriptEngine() 'Check VBScript engine version
Message = " version1" &amp; version1
If version1 = True Then
' Exec Optimization for Read from Standard Output (VBScript &gt; 5.3)
rc = ExecuteRacCommand (racAgentExist, strLaunchRACURL, racCmd)
If rc &lt;&gt; 0 Then
Message = " ERROR: Main: ExecuteRacCommand error : " &amp; rc
RacExitFlag = 1
MOMDebugLog 1, Message
Err.Clear
Exit Function
End If
ElseIf version1 = False Then
' Run , Redirect to file and Read from File (VBScript &lt; 5.3, StdOut not supported)
rc = RunRacCommand (racAgentExist, strLaunchRACURL, racCmd)
Message = " RunRacCommand " &amp; rc
If rc &lt;&gt; 0 Then
Message = " ERROR: Main: RunRACURL error : " &amp; rc
RacExitFlag = 1
MOMDebugLog 1, Message
Err.Clear
Exit Function
End If
Else
Message = " ERROR: CheckVBScriptEngine Error : " &amp; version1
RacExitFlag = 1
MOMDebugLog 1, Message
Err.Clear
Exit Function
End If
End Function

Dim RacExitFlag, Message, RegError
Const RacError= "Error"
'*****************************************************************
' ExecuteRacCommand
' Routine to Exec Cmd and Read From Standard Output
'*****************************************************************
Function ExecuteRacCommand(ByRef RacAgent, ByRef RacUrl, RacadmCmd)
On Error Resume Next
Dim blsRacInstalled, blsRacGen4Plus
Dim RacPath, drive, WshShell
Dim blsRacType
blsRacInstalled = 0 ' IP address Existence
blsRacGen4Plus = 0 ' Port Existence (subset of RacInstalled)
RegError = 0
Dim GetLanNetworking, CurLanNetworking, GetIDString, CommandString

GetPathParameter RacPath, drive
If RacExitFlag = 1 Then
ExecuteRacCommand = -1
Err.Clear
Exit Function
End If

Dim IPStr: IPStr = ""
Dim CmdPrefix: CmdPrefix = "cmd /c """ &amp; RacPath &amp; "\racadm.exe"" " &amp; IPStr
GetIDString = CmdPrefix &amp; " getconfig -g idRacInfo"
GetLanNetworking = CmdPrefix &amp; " getconfig -g cfgLanNetworking"
RacadmCmd = CmdPrefix &amp; " " &amp; RacadmCmd
CurLanNetworking = CmdPrefix &amp; " getconfig -g cfgCurrentLanNetworking"

Set WshShell = CreateObject("WScript.Shell")
CommandString = GetIDString
Message = "ExecuteRacCommand: Cmd for RACType - " &amp; CommandString
MOMDebugLog 1, Message
Dim timer, oShell, objStdOut, strLine, nPos, strRacType
Const TIMEOUT = 20
timer = 0
Set oShell = WshShell.Exec(CommandString)
Do While oShell.Status = 0
WScript.Sleep(1000)
timer = timer + 1
if (timer &gt; TIMEOUT) Then
Message = "Exit ExecCmd. Reason: RACADM not responding"
MOMDebugLog 1, Message
oShell.Terminate()
Exit Do
End If
Loop
Set objStdOut = oShell.StdOut
If Not oShell.StdErr.AtEndOfStream Then
RacadmErrStream = "STDERR: " + oShell.StdErr.ReadAll
Message = "RACADM Standard Error - " &amp; RacadmErrStream
MOMDebugLog 1, Message
ExecuteRacCommand = -1
Err.Clear
Exit Function
Else
Do While Not objStdOut.AtEndOfStream
strLine = objStdOut.ReadLine
If Instr(Lcase(strLine),RacError) Then
RacAgent = 0
Message = "Error in Racadm Output for RACType " &amp; strLine
MOMDebugLog 1, Message
ExecuteRacCommand = -1
Err.Clear
Exit Function
ElseIf Instr(LCase(strLine),Lcase("idRacType")) Then
nPos = Instr(LCase(strLine), "=")
strRacType = Trim(strLine)
strRacType = Mid(strRacType,nPos+1,5)
strRacType = Trim(strRacType)
blsRacType = 1
Message = "Detected DRAC Type (hex)= " &amp; strRacType
End If
Loop
End If
MOMDebugLog 1, Message

oShell.Terminate()
Set oShell = Nothing
Set WshShell = Nothing

MOMDebugLog 1, "blsRacType=" &amp; blsRacType &amp; ", strRacType=" &amp; strRacType
If blsRacType = 1 Then
If Instr(Lcase(strRacType),"6") OR Instr(Lcase(strRacType),"8") OR Instr(Lcase(strRacType),"10") OR Instr(Lcase(strRacType),"11") OR Instr(Lcase(strRacType),"16") OR Instr(Lcase(strRacType),"17") OR Instr(Lcase(strRacType),"32") OR Instr(Lcase(strRacType),"33") OR Instr(Lcase(strRacType),"34") Then
Message = "iDRAC Type = " &amp; strRacType
MOMDebugLog 1, Message
lccFlag = 1
Else
Message = "Not an iDRAC Type = " &amp; strRacType
MOMDebugLog 1, Message
End If
End If
'''
Set oShell = Nothing
Set objStdOut = Nothing


If Err &lt;&gt; 0 Then
ExecuteRacCommand = Err.Number
Message = "ExecuteRacCommand ErrorNo= " &amp; Err.No &amp; ", Description: " &amp; Err.Desc
MOMDebugLog 1, Message
Err.Clear
End If
End Function

'*****************************************************************
' RunRacCommand
'Routine to use Run - Redirect to file and Read from File,Del File
' Arguments: RacAgent for existence of RAC, RACUrl
'*****************************************************************
Function RunRacCommand(ByRef RacAgent, ByRef RacUrl, RacadmCmd)
On Error Resume Next
RegError = 0
Const ForReading = 1
Dim guid1, guid2, guid3, guid4
Dim GetLanNetworking, CurLanNetworking, GetIDString, CommandString
Dim strRacIpAddress

Dim IPStr: IPStr = ""
GetIDString = IPStr &amp; " getconfig -g idRacInfo"
GetLanNetworking = IPStr &amp; " getconfig -g cfgLanNetworking"
RacadmCmd = IPStr &amp; " " &amp; RacadmCmd
CurLanNetworking = IPStr &amp; " getconfig -g cfgCurrentLanNetworking"
Dim blsRacInstalled, RacPath, drive, wintemp_path, filespec
Dim oShell3, rc

blsRacInstalled = 0 ' will have IP address

GetPathParameter RacPath, drive
GetTempFolderPath wintemp_path, drive
GetRACFileGUID guid1, guid2

If RacExitFlag = 1 Then
RunRacCommand = -1
Exit Function
End If

filespec = wintemp_path &amp; "\" &amp; guid1 &amp; ".txt"
GetIDString = "cmd /c " &amp; chr(34) &amp; RacPath &amp; "\racadm.exe" &amp; Chr(34) &amp; GetIDString &amp; " &gt; " &amp; filespec
Message = "Run: Command for DRAC Type - " &amp; GetIDString
MOMDebugLog 1, Message
Set oShell3 = CreateObject ("WScript.Shell")
rc = oShell3.run(GetIDString,0,true)
if (rc &lt;&gt; 0) OR (bFileExists(filespec) = False) Then
Message = " ERROR: PORT: RunRacCommand: OShellRun ERROR: " &amp; rc &amp; " for " &amp; GetIDString
MOMDebugLog 1, Message
rc = DelFile(filespec)
If rc &lt;&gt; 0 Then
Message = "WARNING: - DelFile " &amp; filespec
MOMDebugLog 1, Message
End If
RunRacCommand = -1
Err.Clear
Exit Function
end if
Dim strLine, nPos, strRacType, blsRacType
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile: Set oFile = fso.OpenTextFile(filespec, ForReading, False)
Do While Not oFile.AtEndOfStream
strLine = Trim(oFile.ReadLine)
If Instr(Lcase(strLine),RacError) Then
RacAgent = 0
Message = " ERROR: Error in Racadm Output for idRacInfo " &amp; strLine
MOMDebugLog 1, Message
rc = DelFile(filespec)
If rc &lt;&gt; 0 Then
Message = "WARNING: - DelFile " &amp; filespec
MOMDebugLog 1, Message
End If
RunRacCommand = -1
Err.Clear
Exit Function 'Add MP22UT.X01
End If
If Instr(LCase(strLine),Lcase("idRacType")) Then
nPos = Instr(LCase(strLine), "=")
strRacType = Trim(strLine)
strRacType = Mid(strRacType,nPos+1,5)
strRacType = Trim(strRacType)
Message = " INFO: Detected DRAC Type (hex)= " &amp; strRacType
blsRacType = 1
End If
Loop
MOMDebugLog 1, "blsRacType " &amp; blsRacType &amp; ", strRacType="&amp; strRacType

Set oShell3 = Nothing
'Set objStdOut = Nothing
oFile.close
'Clean up the CLI Output : Delete %WINTEMP% \ %Guid1% .txt
rc = DelFile(filespec)
If rc &lt;&gt; 0 Then
Message = " WARNING:! - DelFile " &amp; filespec
MOMDebugLog 1, Message
End If
Set filespec = Nothing

If blsRacType = 1 Then
GetRACFileGUID guid3, guid4
If Instr(Lcase(strRacType),"10") OR Instr(Lcase(strRacType),"11") Then
lccFlag = 1
End If
Else
Message = "DRAC Type not found via idRacInfo command. "
MOMDebugLog 1, Message
End If ' End of blsRacType IF clause
' Output OMSA CLI to file RACGuid1.txt, wait until RUN Command is completed
' RAC5+ cfgLanNetworking in place of cfgCurrentLanNetworking (Invalid Group)

If Err &lt;&gt; 0 Then
RunRacCommand = Err.Number
Err.Clear
End If
End Function


'*****************************************************************
'GetPathParameter - Common to RunRacCommand and ExecRacUrl
'Routine to get RACADM path and drive letter
' Arguments: Racadm path for executable and drive letter of installation
'*****************************************************************
Function GetPathParameter(ByRef o_racpath, ByRef o_drive)
On Error Resume Next
Dim rac_path, drive_letter, rc
rc = GetRACADMPath(rac_path)
If rc &lt;&gt; 0 Then
Message = "GetPathParameter:GetRACADMPath Error - " &amp; rc
MOMDebugLog 1, Message
RacExitFlag = 1
Err.Clear
Exit Function
Else
Message = "GetPathParameter:GetRACADMPath - " &amp; rac_path
End If

rc = GetRACInstallRoot(drive_letter, rac_path)
If rc &lt;&gt; 0 Then
Message = "GetPathParameter:GetRACInstallRoot Error - " &amp; rc
MOMDebugLog 1, Message
RacExitFlag = 1
Err.Clear
Exit Function
Else
Message = "GetPathParameter:GetRACInstallRoot - " &amp; drive_letter
End If

If RegError = 1 Then
Message = "RAC Hardware / Agent not installed on Server"
MOMDebugLog 1, Message
RacExitFlag = 1
Err.Clear
Exit Function
End If

o_racpath = rac_path
o_drive = drive_letter

If Err &lt;&gt; 0 Then
GetPathParameter = Err.Number
Err.Clear
End If
End Function

'*************************************************************************
' Function : GetRACInstallRoot()
' Desc : To determine RAC Install Drive
' Arguments : ByRef, driveletter and RACadmPath
'*************************************************************************
Function GetRACInstallRoot(ByRef path, ByVal RACInstallPath)
On Error Resume Next
' Return the root drive of the OMInstall Path
path = Left(RACInstallPath, 2)
If Err &lt;&gt; 0 Then
GetRACInstallRoot = Err.Number
Err.Clear
End If
End Function

'*****************************************************************
'GetTempFolderPath
'Routine to Get Win Temp Folder path
'*****************************************************************
Function GetTempFolderPath(ByRef WinTempFolder, ByVal drive_letter)
On Error Resume Next
Dim FldrExistFlag, fso
FldrExistFlag = False
dim wshShell : Set wshShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wshShell.Environment
dim strSysTempFolder : strSysTempFolder = wshSysEnv("TEMP")
dim wshPrcEnv : Set wshPrcEnv = wshShell.Environment("Process")
strSysTempFolder = Replace(strSysTempFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)
WinTempFolder = strSysTempFolder

Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(WinTempFolder)) Then
FldrExistFlag = True
Else
FldrExistFlag = False
End If
If WinTempFolder = "" OR FldrExistFlag = False Then
WinTempFolder = drive_letter
End If
Message = "Current CLI output will be stored in Folder - " &amp; WinTempFolder

Set wshShell = Nothing
Set wshSysEnv = Nothing
Set strSysTempFolder = Nothing
Set wshPrcEnv = Nothing

If Err &lt;&gt; 0 Then
GetTempFolderPath = Err.Number
Err.Clear
End If
End Function

'*****************************************************************
'GetRACFileGUID
'Routine to generate 2 unique GUIDs for ip and port info files
' Used to serve concurrency file access by different modules
'*****************************************************************
Function GetRACFileGUID(ByRef guid3, ByRef guid4)
On Error Resume Next
Dim TypeLib, NewGUID
Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
guid3 = (left(NewGUID, len(NewGUID)-2))
Set TypeLib = Nothing

Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
guid4 = (left(NewGUID, len(NewGUID)-2))
Set TypeLib = Nothing
End Function

'*****************************************************************
'GetRacadmPath
'Routine to read the registry to query the OMSA Install Path
'*****************************************************************
Function GetRACADMPath(ByRef o_sPath)
On Error Resume Next
Const DEF_RACADM_PATH = "C:\Program Files\Dell\OpenManage\RAC\MN"
Const RACADM_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Dell Computer Corporation\OpenManage\Remote Access Card Managed Node\PATH"
Const RACADM64_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432node\Dell Computer Corporation\OpenManage\Remote Access Card Managed Node\PATH"
Const REM_RACADM_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Dell Computer Corporation\OpenManage\Remote Access Card Management Station\Path"
Const REM_RACADM64_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Dell Computer Corporation\OpenManage\Remote Access Card Management Station\Path"
Dim oShell, strRacadmKey, tmp

strRacadmKey = RACADM_REG_INTALL_PATH
Set oShell = CreateObject ("WScript.Shell")
o_sPath = ""
o_sPath = oShell.RegRead(strRacadmKey)

If o_sPath = "" Then
o_sPath = oShell.RegRead(RACADM64_REG_INTALL_PATH)
If Err &lt;&gt; 0 Then
Err.Clear
End If
End If
If o_sPath = "" Then
o_sPath = oShell.RegRead(REM_RACADM_REG_INTALL_PATH)
If Err &lt;&gt; 0 Then
Err.Clear
End If
End If
If o_sPath = "" Then
o_sPath = oShell.RegRead(REM_RACADM64_REG_INTALL_PATH)
If Err &lt;&gt; 0 Then
Err.Clear
End If
End If

If o_sPath = "" Then
tmp = DEF_RACADM_PATH &amp; "\racadm.exe"
If(bFileExists(tmp)) Then
o_sPath = DEF_RACADM_PATH
Message = "RACADM Registry is empty, Using Default Path" &amp; DEF_RACADM_PATH
MOMDebugLog 1, Message
Err.Clear
Else
RegError = 1
End If
End If
If Err &lt;&gt; 0 Then
GetRACADMPath = Err.Number
Err.Clear
End If
Set oShell = Nothing
End Function


'*****************************************************************
' Function ParseStorageXML
' Get the Controller data from OMSS StorageController XML Output
'*****************************************************************
Function ParseStorageXML(ByVal storagefilepath)
Dim StorageHealth, contr_health, controller_arr, contrName, contrNameVal
Dim firmwareVerVal, driverVerVal, pciSlotVal, targetIdVal
Dim reqFwVerVal,channelVal,slotIdVal,reqDrvrVerVal,globalNoVal
Dim xmlDoc, i, str, TopNode, TopNodelist, root, len, slotId

If(bFileExists(storagefilepath)) Then
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
If (IsObject(xmlDoc) = True) Then
xmlDoc.async = "false"
xmlDoc.load(storagefilepath)
If (xmlDoc.parseError.errorCode &lt;&gt; 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
Message = "XML Parse Error Reason: " &amp; myErr.reason
MOMDebugLog 1, Message
Message = "XML Parse Error Line: " &amp; myErr.line
MOMDebugLog 1, Message
Message = "XML Parse Error Character: " &amp; myErr.linepos
MOMDebugLog 1, Message
Message = "XML Parse Error Text: " &amp; myErr.srcText
MOMDebugLog 1, Message
DelFile(storagefilepath)
Exit Function
End If

Set root = xmlDoc.documentElement
MOMDebugLog 1, "Root Node is " &amp; root.nodeName
Set TopNodeList = root.selectNodes("Controllers/DCStorageObject")
For Each TopNode In TopNodeList
If TopNode.hasChildNodes Then
MOMDebugLog 1, "node has child nodes:" &amp; TopNode.nodeName
contrNameVal = GetTagValue(TopNode, "Name")
pciSlotVal = GetTagValue(TopNode, "PCISlot")
firmwareVerVal = GetTagValue(TopNode, "FirmwareVer")
driverVerVal = GetTagValue(TopNode, "CurrentDriverVersion")
reqFwVerVal = GetTagValue(TopNode, "RequiredFirmwareVersion")
channelVal = GetTagValue(TopNode, "Channels")
globalNoVal = GetTagValue(TopNode, "GlobalNo")
reqDrvrVerVal = GetTagValue(TopNode, "RequiredDriverVersion")
targetIdVal = GetTagValue(TopNode, "TargetID")

If ((StrComp(Trim(pciSlotVal),"0") = 0) Or (StrComp(Trim(pciSlotVal),"-1") = 0) Or (StrComp(Trim(pciSlotVal),"2147483648") = 0 )) Then
slotId = "Embedded"
ElseIf ( StrComp(Trim(pciSlotVal),"2147483649") = 0 ) Then
slotId = "Slot Not Available"
Else
slotId = "PCI Slot" &amp; Trim(pciSlotVal)
End If

MOMDebugLog 1, "slotId:" &amp; slotId
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.StorageController']$")
MOMDebugLog 1, "Adding Dell.WindowsServer.StorageController class"
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
MOMDebugLog 1, "Adding TargetComputer:" &amp; TargetComputer
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", TargetComputer)

call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/DeviceID$", globalNoVal)
MOMDebugLog 1, "Adding globalNoVal:" &amp; globalNoVal
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", contrNameVal)
MOMDebugLog 1, "Adding contrNameVal:" &amp; contrNameVal
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/DriverVer$", driverVerVal)
MOMDebugLog 1, "Adding driverVerVal:" &amp; driverVerVal
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/FirmwareVer$", firmwareVerVal)
MOMDebugLog 1, "Adding firmwareVerVal:" &amp; firmwareVerVal

call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/MinReqFirmwareVer$", reqFwVerVal)
MOMDebugLog 1, "Adding reqFwVerVal:" &amp; reqFwVerVal

call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/NumOfConnectors$", channelVal)
MOMDebugLog 1, "Adding channelVal:" &amp; channelVal

call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/SlotID$", slotId)
MOMDebugLog 1, "Adding slotId:" &amp; slotId

call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/MinReqDriverVer$", reqDrvrVerVal)
MOMDebugLog 1, "Adding reqDrvrVerVal:" &amp; reqDrvrVerVal

call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.StorageController']/SCSIInitiatorID$", targetIdVal)
MOMDebugLog 1, "Adding targetIdVal:" &amp; targetIdVal

call oDiscoveryData.AddInstance(oInst)
MOMDebugLog 1, "Adding the instance:"

storageFlag = 1
MOMDebugLog 1, "Adding storageFlag=:" &amp; storageFlag

end if
Next
Else
Message = "Error: DOM object not created using CreateObject - Microsoft.XMLDOM"
MOMDebugLog 1, Message
End If
Else
Message = "Storage CLI XML Output File does not exist - " &amp; storagefilepath
MOMDebugLog 1, Message
End If
End Function

'*****************************************************************
Function GetTagValue(ByRef TopNode, ByVal tagName)
Dim value, NodeList, Node, len
Set NodeList = TopNode.selectNodes(tagName)
len = Nodelist.Length
if len &gt; 0 then
Set Node = NodeList.item(0)
value = Node.text
else
value = "Not Available"
end if
MOMDebugLog 1, "Name:" &amp; tagName &amp; ", value:" &amp; value
GetTagValue = value
End Function

'*****************************************************************
Sub MOMDebugLog (ByVal debugLevel, ByVal Message)
On Error Resume Next
If (debugLevel &gt; 0) and (debugLevel &lt;= logLevel) Then
objLogTextFile.WriteLine(Now() &amp; " ---- " &amp; Message)
Err.Clear
End If
End Sub

'*****************************************************************
'GetTempFolderPath
'Routine to Get Win Temp Folder path
'*****************************************************************
Function GetTempFolderPath(ByRef WinTempFolder, ByVal drive_letter)
On Error Resume Next
Dim FldrExistFlag, fso
FldrExistFlag = False
dim wshShell : Set wshShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wshShell.Environment
dim strSysTempFolder : strSysTempFolder = wshSysEnv("TEMP")
dim wshPrcEnv : Set wshPrcEnv = wshShell.Environment("Process")
strSysTempFolder = Replace(strSysTempFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)
WinTempFolder = strSysTempFolder

Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(WinTempFolder)) Then
FldrExistFlag = True
Else
FldrExistFlag = False
End If

If WinTempFolder = "" OR FldrExistFlag = False Then
WinTempFolder = drive_letter
End If

Set wshShell = Nothing
Set wshSysEnv = Nothing
Set strSysTempFolder = Nothing
Set wshPrcEnv = Nothing

If Err &lt;&gt; 0 Then
GetTempFolderPath = Err.Number
Err.Clear
End If
End Function

'*****************************************************************
'GetOMReportFileGUID
'Routine to generate unique GUIDs for OMREPORT FILE
'*****************************************************************
Function GetOMReportFileGUID(ByRef o_guid)
On Error Resume Next
Dim TypeLib, NewGUID
Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
o_guid = (left(NewGUID, len(NewGUID)-2))
Set TypeLib = Nothing
End Function

' *** Add double query fix

' Function to retrieve the object

Function GetObjectSet(ByRef objDellConnection, SelectQuery, Attribute, objName)
Dim retry, retryFlag
Dim objItem, arrURL, logMessage

On Error Resume Next
RetryFlag = False
For retry = 0 To 1
MOMDebugLog 1, "Retrying for " &amp; retry &amp; " time..."
Set GetObjectSet = objDellConnection.ExecQuery(SelectQuery)
LogErrorNumber(objName)
If (GetObjectSet is Nothing) Or (IsNull(GetObjectSet)) Then
logMessage = "INFO: Unable to retrieve " &amp; objName &amp; " Attributes"
MOMDebugLog 1, logMessage
WScript.Sleep(1000)
RetryFlag = True
Else
logMessage= "INFO: " &amp; objName &amp; " attributes retrieved successfully"
MOMDebugLog 1, logMessage
If Attribute = "__COUNT__" Then
Exit For
End If
For Each objItem in GetObjectSet
If LogErrorNumber(objName) = 0 Then
If Not objItem is nothing Then
Dim attrVal : attrVal = objItem.Properties_.Item(Attribute)
If IsNull(attrVal) Or Len(attrVal) &lt;= 0 Then
MOMDebugLog 1, Attribute &amp; " value is null or empty"
RetryFlag = True
WScript.Sleep(500)
Exit For
Else
Exit Function
End If
End If
End If
Next
If RetryFlag = False Then
Exit For
End If
End If
Next
End Function

Function LogErrorNumber(objName)
Dim logMessage
LogErrorNumber = Err.Number
If Err.Number &lt;&gt; 0 Then
Select Case Err.Number
Case -2147749904
logMessage = "CIM Object not found"
Case -2147749902
logMessage = "Dell CIM object not found"
Case -2147023169
logMessage = "RPC Failure occurred for namespace root-cimv2-dell"
Case -2147217389
logMessage = "Please Install/Re-Install ServerAdministrator on Dell Server!"
Case -2147217394 '0x8004100E
logMessage = "Not able to find Dell CIM object"
Case -2147217392 '0x8004100C
logMessage = "Not able to find the collection"
Case -2147749890
logMessage = "Object cannot be found"
Case -2147749892
logMessage = "Object cannot be found"
Case Else
logMessage = "Unable to retrieve " &amp; objName
logMessage = logMessage &amp; " Err Number:" &amp; Err.Number
logMessage = logMessage &amp; " Err Descr:" &amp; Err.Description
End Select
MOMDebugLog 1, "ERROR: " &amp; logMessage
End If
End Function
</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>