Fujitsu PRIMERGY Windows Server Discovery Data Source

Fujitsu.Servers.PRIMERGY.Windows.ServerDiscoveryDataSource (DataSourceModuleType)

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource System.CommandExecuterDiscoveryDataSource Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval SecondsServer Discovery Data Source - Parameter 'IntervalSeconds'

Source Code:

<DataSourceModuleType ID="Fujitsu.Servers.PRIMERGY.Windows.ServerDiscoveryDataSource" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="IntervalSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="System!System.CommandExecuterDiscoveryDataSource">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<ApplicationName>%windir%\System32\cscript.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>$file/PRIMERGYServerDiscoveryComplete.vbs$ $MPElement$ $Target/Id$ $Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$ $Target/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</CommandLine>
<TimeoutSeconds>300</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>PRIMERGYServerDiscoveryComplete.vbs</Name>
<Contents><Script>'-------------------------------------------------------------------
' Fujitsu Technology Solutions
' Copyright (C) Fujitsu Technology Solutions 2008 - 2016
'-------------------------------------------------------------------
Option Explicit
SetLocale("en-us")
'-------------------------------------------------------------------
' SCOM.vbs
'-------------------------------------------------------------------

Const cMAXINDEX = 196

'-----------------------------------

Dim componentStatusArray, componentNameArray, componentInfoArray, componentCount, componentCountEmpty
ReDim componentStatusArray(cMAXINDEX + 2), componentNameArray(cMAXINDEX + 2), componentInfoArray(cMAXINDEX + 2)
Dim componentNames, componentStatus, componentInfos, componentHealth

'-----------------------------------

Const PROCESSOR = 0
Const MEMORY = 1
Const STORAGE = 2
Const NETWORK = 3
Const MGMTCTRL = 4
Const FANS = 5
Const TEMPERATURE = 6
Const VOLTAGES = 7
Const POWERSUPPLY = 8
Const POWERCONSUMP = 9
Const RAIDSUBSYSTEM = 10
Const PHYSICALDISK = 11
Const LOGICALDRIVE = 12
Const DRIVERMONITOR = 13 ' currently not supported subsystem
Const PCISLOTS = 14 ' currently not supported subsystem
Const OTHER = 15 ' make sure this is the last subsystem
' continue with specific components
Const SVOVERALL = 16
Const SVVERSION = 17
Const SELFTEST = 18
Const TPMMODULE = 19
Const RAIDOVERALL = 20
Const RAIDVERSION = 21 ' make sure this is the last component

Dim ComponentsList, ComponentsStateList, ComponentsPYServerData, ComponentsPYServerDataValid
ReDim ComponentsList(OTHER)
ComponentsList(PROCESSOR) = "Processors"
ComponentsList(MEMORY) = "Memory"
ComponentsList(STORAGE) = "Storage"
ComponentsList(NETWORK) = "Networks (Ethernet)"
ComponentsList(MGMTCTRL) = "Management Controller"
ComponentsList(FANS) = "Fans (Cooling)"
ComponentsList(TEMPERATURE) = "Temperatures"
ComponentsList(VOLTAGES) = "Voltages"
ComponentsList(POWERSUPPLY) = "Power Supplies"
ComponentsList(POWERCONSUMP) = "Power Consumption"
ComponentsList(RAIDSUBSYSTEM) = "RAID Subsystem"
ComponentsList(PHYSICALDISK) = "RAID Physical Disks"
ComponentsList(LOGICALDRIVE) = "RAID Logical Drives"
ComponentsList(DRIVERMONITOR) = "Driver Monitor"
ComponentsList(PCISLOTS) = "PCI Slots"
ComponentsList(OTHER) = "Other Components"
ReDim ComponentsStateList(OTHER)
ComponentsStateList(PROCESSOR) = "Processors"
ComponentsStateList(MEMORY) = "Memory"
ComponentsStateList(STORAGE) = "Storage"
ComponentsStateList(NETWORK) = "Networks"
ComponentsStateList(MGMTCTRL) = "ManagementController"
ComponentsStateList(FANS) = "Fans"
ComponentsStateList(TEMPERATURE) = "TemperatureSensors"
ComponentsStateList(VOLTAGES) = "VoltageSensors"
ComponentsStateList(POWERSUPPLY) = "PowerSupplies"
ComponentsStateList(POWERCONSUMP) = "PowerConsumption"
ComponentsStateList(RAIDSUBSYSTEM) = "RaidSubsystem"
ComponentsStateList(PHYSICALDISK) = "RaidPhysicalDisks"
ComponentsStateList(LOGICALDRIVE) = "RaidLogicalDrives"
ComponentsStateList(DRIVERMONITOR) = "DriverMonitor"
ComponentsStateList(PCISLOTS) = "PCISlots"
ComponentsStateList(OTHER) = "OtherComponents"
ReDim ComponentsPYServerData(OTHER)
ReDim ComponentsPYServerDataValid(OTHER)

Dim cimHealthStateSubsystem, scciHealthStateSubsystem
ReDim cimHealthStateSubsystem(RAIDVERSION)
cimHealthStateSubsystem(PROCESSOR) = "System Processors"
cimHealthStateSubsystem(MEMORY) = "Memory Modules"
cimHealthStateSubsystem(STORAGE) = "Mass Storage Adapters"
cimHealthStateSubsystem(NETWORK) = "Network"
cimHealthStateSubsystem(MGMTCTRL) = "" ' no SVAgent State available
cimHealthStateSubsystem(FANS) = "Fans"
cimHealthStateSubsystem(TEMPERATURE) = "Temperature"
cimHealthStateSubsystem(VOLTAGES) = "System Board Voltages"
cimHealthStateSubsystem(POWERSUPPLY) = "Power Supply"
cimHealthStateSubsystem(POWERCONSUMP) = "Power Level"
cimHealthStateSubsystem(RAIDSUBSYSTEM) = "ServerView RAID System"
cimHealthStateSubsystem(PHYSICALDISK) = "RAID Physical disks"
cimHealthStateSubsystem(LOGICALDRIVE) = "RAID Logical drives"
cimHealthStateSubsystem(DRIVERMONITOR) = "Monitored Components"
cimHealthStateSubsystem(PCISLOTS) = "PCI Slots"
cimHealthStateSubsystem(OTHER) = "System"
cimHealthStateSubsystem(SVOVERALL) = ""
cimHealthStateSubsystem(SVVERSION) = ""
cimHealthStateSubsystem(SELFTEST) = "BIOS Selftest"
cimHealthStateSubsystem(TPMMODULE) = "Trusted Platform Module"
cimHealthStateSubsystem(RAIDOVERALL) = ""
cimHealthStateSubsystem(RAIDVERSION) = ""

ReDim scciHealthStateSubsystem(RAIDVERSION)
scciHealthStateSubsystem(PROCESSOR) = "Systemboard - SvCPUs"
scciHealthStateSubsystem(MEMORY) = "Systemboard - SvMemModules"
scciHealthStateSubsystem(STORAGE) = "MassStorage - SvMassStorageAdapters"
scciHealthStateSubsystem(NETWORK) = "Network - SvNetworkAdapters"
scciHealthStateSubsystem(MGMTCTRL) = "" ' no SVAgent State available
scciHealthStateSubsystem(FANS) = "Environment - SvFans"
scciHealthStateSubsystem(TEMPERATURE) = "Environment - SvTempSensors"
scciHealthStateSubsystem(VOLTAGES) = "Systemboard - SvVoltages"
scciHealthStateSubsystem(POWERSUPPLY) = "PowerSupply - SvPowerSupplies"
scciHealthStateSubsystem(POWERCONSUMP) = "PowerSupply - SvPowerLevel"
scciHealthStateSubsystem(RAIDSUBSYSTEM) = "MassStorage - SvRaidAura"
scciHealthStateSubsystem(PHYSICALDISK) = "MassStorage - SvRaidPhysicalDisks"
scciHealthStateSubsystem(LOGICALDRIVE) = "MassStorage - SvRaidLogicalDrives"
scciHealthStateSubsystem(DRIVERMONITOR) = "DrvMonitor - SvMonitoredComponents"
scciHealthStateSubsystem(PCISLOTS) = "Systemboard - SvPCISlots"
scciHealthStateSubsystem(OTHER) = "System"
scciHealthStateSubsystem(SVOVERALL) = ""
scciHealthStateSubsystem(SVVERSION) = ""
scciHealthStateSubsystem(SELFTEST) = "Systemboard - SvBIOS"
scciHealthStateSubsystem(TPMMODULE) = "Systemboard - SvTPM"
scciHealthStateSubsystem(RAIDOVERALL) = ""
scciHealthStateSubsystem(RAIDVERSION) = ""

Const STATUS_NONE = "None"
Const STATUS_ERROR = "Error"
Const STATUS_DEGRADED = "Degraded"
Const STATUS_OK = "OK"
Const STATUS_UNKNOWN = "Unknown"
Const STATUS_NOTPRESENT = "Not Present"
Const STATUS_NOTMANAGEABLE = "Not Manageable"
Const STATUS_INVALID = "Invalid"
Const STATUS_COMMERR = "Communication Error"
Const STATUS_NOSTATE = "No State"

Dim scciHealthStateString(8)
scciHealthStateString(0) = STATUS_UNKNOWN
scciHealthStateString(1) = STATUS_OK
scciHealthStateString(2) = STATUS_DEGRADED
scciHealthStateString(3) = STATUS_ERROR
scciHealthStateString(4) = STATUS_NOTPRESENT
scciHealthStateString(5) = STATUS_NOTMANAGEABLE
scciHealthStateString(6) = STATUS_INVALID
scciHealthStateString(7) = STATUS_COMMERR
scciHealthStateString(8) = STATUS_NOSTATE

Dim SCOM_HealthState(31)
SCOM_HealthState(0) = STATUS_UNKNOWN
SCOM_HealthState(5) = STATUS_OK
SCOM_HealthState(10) = STATUS_DEGRADED
SCOM_HealthState(15) = STATUS_DEGRADED
SCOM_HealthState(20) = STATUS_ERROR
SCOM_HealthState(25) = STATUS_ERROR
SCOM_HealthState(30) = STATUS_ERROR

'-----------------------------------

Const INFORMATIONAL_EVENT = 0
Const ERROR_EVENT = 1
Const WARNING_EVENT = 2

'-----------------------------------

Dim oAPI

'-----------------------------------

'****************************************************************

'*** LogScriptEvent: Creates an entry in OM eventlog
Function LogScriptEvent(EventID, EventType, sMessage)
Select Case EventType
Case ERROR_EVENT DebugOut MPScript &amp; " ERROR_EVENT_" &amp; EventID &amp; ": " &amp; sMessage, DBG_ALL
Case WARNING_EVENT DebugOut MPScript &amp; " WARNING_EVENT_" &amp; EventID &amp; ": " &amp; sMessage, DBG_ALL
Case INFORMATIONAL_EVENT DebugOut MPScript &amp; " INFORMATIONAL_EVENT_" &amp; EventID &amp; ": " &amp; sMessage, DBG_ALL
End Select
If insideMP = true Then
Call oAPI.LogScriptEvent(MPScript, EventID, EventType, sMessage)
End If
End Function

'*************************************************************
'*************************************************************
'*************************************************************


'-------------------------------------------------------------------
' Fujitsu Technology Solutions
' Copyright (C) Fujitsu Technology Solutions 2008 - 2016
'
' DataRequest.vbs
'-------------------------------------------------------------------

Const SVAGENTVERSION_MIN = "6.00.00"
Const SVCIMVERSION_MIN = "9.99.99"

Const SVRAIDVERSION_BASE = "3.1.4"
Const SVRAIDVERSION_MIN = "6.0.3"

Const SCCISLEEPTIME = 100
Const wmiRetries = 5
Const waitTimeMin = 100
Const waitTimeMax = 1000

Const cimv2NS = "\root\cimv2"
Const svsNS = "\root\svs"

Const IPMI_NETFN_APP = &amp;H06
Const IPMI_NETFN_OEM_WITH_IANA = &amp;H2E
' IPMI NetFn Application (6) Command definitions
Const IPMI_APP_GET_DEVICE_ID = &amp;H01
Const IPMI_APP_GET_SELF_TEST_RESULTS = &amp;H04

Dim WMIInstanceValid
Dim oSwitch

'****************************************************************

Function WMIQuery(TargetComputer, sNamespace, sQuery, bErrorFlag)
Dim oInst, wmiNameSpace, waitMS, retry, ErrorNumber
Dim wbemFlagReturnWhenComplete: wbemFlagReturnWhenComplete = 0

DebugOut "WMIQuery: TargetComputer=" &amp; TargetComputer &amp; " Namespace=" &amp; sNamespace &amp; " Query=" &amp; sQuery, DBG_DESC

WMIInstanceValid = FALSE
wmiNameSpace = "winmgmts:{impersonationLevel=impersonate}\\" &amp; "." &amp; sNamespace

On Error Resume Next

For retry=0 To wmiRetries-1
Err.Clear()
' make sure ExecQuery is executed synchronously
Set oInst = GetObject(wmiNameSpace).ExecQuery(sQuery, "WQL", wbemFlagReturnWhenComplete)

' Check if WMI returned data.
' Parallel WMI access sometimes results in incomplete/corrupted data which will crash the object count.
' We use this to set Err.Number, which will otherwise be 0
DebugOut "WMIQuery: Got " &amp; oInst.Count &amp; " instances from WMI", DBG_DESC
ErrorNumber = Err.Number

If IsEmpty(oInst) Or ErrorNumber &lt;&gt; 0 Then
If retry &lt; wmiRetries-1 Then
DebugOut "WMIQuery: Got no Data from WMI class '" &amp; sNamespace &amp; "\" &amp; sInstance &amp;"', " &amp; retry+1 &amp; ". Retry.", DBG_DESC

Randomize
waitMS = Int((waitTimeMax - waitTimeMin + 1) * Rnd) + waitTimeMin ' wait random time span in preconfigured range
DebugOut "WMIQuery: Waiting " &amp; waitMS &amp; " milliseconds", DBG_DATA

'*** do one retry after a short wait ...
WScript.Sleep waitMS
Else 'no retry left, we are done
DebugOut "WMIQuery: Still no Data from WMI, give up", DBG_DATA
If bErrorFlag = True Then
LogScriptEvent 130, ERROR_EVENT, "Class '" &amp; sNameSpace &amp; "\" &amp; sInstance &amp; "' returned invalid data."
End If
End If
Else
Set WMIQuery = oInst
WMIInstanceValid = TRUE
Exit For
End If
Next

On Error Goto 0
End Function

'****************************************************************

Function GetScciData(opCode, opCodeExt, objIndex, cabID)
Dim scciValue, ret

If IsObject(oSwitch) = true Then
On Error Resume Next
scciValue = oSwitch.VBRequest(opCode, opCodeExt, objIndex, cabID, 0, 0, 0, ret)
If ret &lt;&gt; 0 Then
' this SCCI value does not exist
DebugOut "GetScciData: No Data for opCode=0x" &amp; Hex(opCode) &amp; " opCodeExt=0x" &amp; Hex(opCodeExt) &amp; " objIndex=" &amp; objIndex &amp; " cabID=" &amp; cabID, DBG_DESC
scciValue = Null
End If
On Error Goto 0
Else
scciValue = Null
End If

If ret = 0 Then
If VarType(scciValue) &lt; 8000 Then
DebugOut "GetScciData: opCode=0x" &amp; Hex(opCode) &amp; " opCodeExt=0x" &amp; Hex(opCodeExt) &amp; " objIndex=" &amp; objIndex &amp; " cabID=" &amp; cabID &amp; " -&gt; scciValue = '" &amp; scciValue &amp; "'", DBG_DESC
Else
DebugOut "GetScciData: opCode=0x" &amp; Hex(opCode) &amp; " opCodeExt=0x" &amp; Hex(opCodeExt) &amp; " objIndex=" &amp; objIndex &amp; " cabID=" &amp; cabID &amp; " -&gt; scciValue = '[Array]'", DBG_DESC
End If
End If

GetScciData = scciValue
End Function

'****************************************************************

Function GetScciProperty(opCode, opCodeExt, objIndex, cabID, strProperty)
Dim scciValue, ret

If IsObject(oSwitch) = true Then
On Error Resume Next
scciValue = oSwitch.VBRequest(opCode, opCodeExt, objIndex, cabID, "" &amp; strProperty, Len(strProperty)+1, 0, ret)
If ret &lt;&gt; 0 Then
' this SCCI value does not exist
DebugOut "GetScciProperty: No Data for opCode=0x" &amp; Hex(opCode) &amp; " opCodeExt=0x" &amp; Hex(opCodeExt) &amp; " objIndex=" &amp; objIndex &amp; " cabID=" &amp; cabID &amp; " '" &amp; strProperty &amp; "' " &amp; Len(strProperty)+1 &amp; " 0", DBG_DESC
scciValue = Null
End If
On Error Goto 0
Else
scciValue = Null
End If

If ret = 0 Then
If VarType(scciValue) &lt; 8000 Then
DebugOut "GetScciProperty: opCode=0x" &amp; Hex(opCode) &amp; " opCodeExt=0x" &amp; Hex(opCodeExt) &amp; " objIndex=" &amp; objIndex &amp; " cabID=" &amp; cabID &amp; " '" &amp; strProperty &amp; "' " &amp; Len(strProperty)+1 &amp; " 0 -&gt; scciValue = '" &amp; scciValue &amp; "'", DBG_DESC
Else
DebugOut "GetScciProperty: opCode=0x" &amp; Hex(opCode) &amp; " opCodeExt=0x" &amp; Hex(opCodeExt) &amp; " objIndex=" &amp; objIndex &amp; " cabID=" &amp; cabID &amp; " '" &amp; strProperty &amp; "' " &amp; Len(strProperty)+1 &amp; " 0 -&gt; scciValue = '[Array]'", DBG_DESC
End If
End If

GetScciProperty = scciValue
End Function

'****************************************************************

' main functionality from here:
' https://blogs.msdn.microsoft.com/dsadsi/2009/02/12/working-with-the-microsoft_ipmi-driver-class-to-retrieve-driver-specific-information-part-1/
Function doIpmiRequest(oIPMI, oClass, NetFunc, Lun, RAddr, Cmd, rData, outParams)
Dim inParams, rDataItem, rDataSize, i

rDataSize = UBound(rData) + 1
DebugOut "doIpmiRequest (" &amp; NetFunc &amp; ", " &amp; Lun &amp; ", " &amp; RAddr &amp; ", " &amp; Cmd &amp; ", Array(" &amp; rDataSize &amp; "))", DBG_INFO

Set inParams = oClass.Methods_("RequestResponse").InParameters.SpawnInstance_
inParams.networkfunction = NetFunc
inParams.lun = Lun
inParams.responderaddress = RAddr
inParams.command = Cmd
inParams.RequestDataSize = rDataSize
inParams.RequestData = rData
For i=0 To rDataSize-1
DebugOut "inParams.RequestData(" &amp; i &amp; "): 0x" &amp; Right("00" &amp; Hex(Data(i)), 2), DBG_DESC
Next

DebugOut "inParams.GetObjectText_ :", DBG_DESC
DebugOut inParams.GetObjectText_, DBG_DESC

Set outParams = oIPMI.ExecMethod_("RequestResponse", inParams)

DebugOut "outParams.GetObjectText_ :", DBG_DESC
DebugOut outParams.GetObjectText_, DBG_DESC

'DebugOut "Number of ResponseData: " &amp; outParams.ResponseDataSize, DBG_INFO
For i=0 To outParams.ResponseDataSize-1
DebugOut "OutParams.ResponseData(" &amp; i &amp; "): 0x" &amp; Right("00" &amp; Hex(outParams.ResponseData(i)), 2), DBG_DESC
Next

'DebugOut "Completion Code: " &amp; outParams.CompletionCode, DBG_INFO
doIpmiRequest = outParams.CompletionCode
End Function

'****************************************************************
'****************************************************************
'****************************************************************

'-------------------------------------------------------------------
' Fujitsu Technology Solutions
' Copyright (C) Fujitsu Technology Solutions 2008 - 2016
'
' Logging.vbs
'-------------------------------------------------------------------

Const MPVERSION = "8.2.2.0"

'-------------------------------------------------------------------

Dim DebugMode
Dim DebugFile
Dim DebugOverWrite
Dim DebugTest
Dim DebugLevel

DebugMode = false
DebugFile = false
DebugOverWrite = true
Const DBG_LOGDAYSOLD = 30

'DebugLevel options are defined in bits and may be combined using binary Or
Const DBG_NO = 0 ' 0000: print no debug lines
Const DBG_INFO = 1 ' 0001: print informational debug lines
Const DBG_DATA = 2 ' 0010: print SCCI/CIM data related debug lines
Const DBG_DESC = 4 ' 0100: print lines relevant for documentation document
Const DBG_SCOM = 8 ' 1000: print SCOM related information
Const DBG_ALL = 3 ' 0011: standard output

Dim oFSO, oLogStream, lineCounter
Dim LogFileDir, LogFilePath, LogFileDirBase

Dim SVISCOMName
SVISCOMName = "SVISCOM-Win"

Const SVISCOMLogIniName = "\SVISCOMLog.ini"
Const SVISCOMLogIn_Name = "\SVISCOMLog.in_"

'****************************************************************

Sub PrepareLogging(TargetComputer, LogFileName, SectionIni, Component)
' get the system environment variable TEMP (usually: C:\Windows\TEMP), depending on e.g. partition
Dim WshShell, EnvVar, TEMP, SYSTEMDRIVE
Dim LogFileTemp, SVISCOMLogIni, SVISCOMLogIn_

' Shell object for system access
Set WshShell = WScript.CreateObject("WScript.Shell")
Set EnvVar = WshShell.Environment("PROCESS")

' get the system environment variable TEMP (usually: C:\Windows\TEMP), depending on e.g. partition
TEMP = EnvVar.Item("TEMP")
SYSTEMDRIVE = EnvVar.Item("SYSTEMDRIVE")

If Len(TEMP) &gt; 0 Then
' use this system temp directory
LogFileTemp = TEMP
Else
If Len(SYSTEMDRIVE) &gt; 0 Then
LogFileTemp = SYSTEMDRIVE &amp; "\temp"
Else
' can't help it - try:
LogFileTemp = "C:\temp"
End If
End If
LogFileDir = LogFileTemp &amp; "\SVISCOM\" &amp; SVISCOMName
LogFileDirBase = LogFileTemp &amp; "\SVISCOM"
SVISCOMLogIni = LogFileDir &amp; SVISCOMLogIniName
SVISCOMLogIn_ = LogFileDir &amp; SVISCOMLogIn_Name
LogFilePath = LogFileDir &amp; LogFileName &amp; ".log"
If Component = "" Then
LogFilePath = LogFileDir &amp; LogFileName &amp; TargetComputer &amp; ".log"
Else
LogFilePath = LogFileDir &amp; LogFileName &amp; TargetComputer &amp; "_" &amp; Component &amp; ".log"
End If

' get setting for DebugMode and DebugFile
If DebugMode = false Then
Call GetLogFileIni(SVISCOMLogIni, SectionIni, "")
' Default DebugLevel: All
If DebugLevel = DBG_NO Then DebugLevel = DBG_ALL End If
End If

' set log file name and create file; only now logging to file can start
If DebugFile = true Then
CreateLogFile(TargetComputer)
End If

DebugOut "TEMP = " &amp; TEMP, DBG_INFO
DebugOut "SYSTEMDRIVE = " &amp; SYSTEMDRIVE, DBG_INFO
DebugOut "LogFileDirBase = " &amp; LogFileDirBase, DBG_INFO
DebugOut "LogFileDir = " &amp; LogFileDir, DBG_INFO
DebugOut "SVISCOMLogIni = " &amp; SVISCOMLogIni, DBG_INFO
DebugOut "SVISCOMLogIn_ = " &amp; SVISCOMLogIn_, DBG_INFO
DebugOut "TargetComputer = " &amp; TargetComputer, DBG_INFO
DebugOut "LogFileName = " &amp; LogFileName, DBG_INFO
DebugOut "LogFilePath = " &amp; LogFilePath, DBG_INFO
DebugOut "DebugMode = " &amp; DebugMode, DBG_INFO
DebugOut "OverWrite = " &amp; DebugOverWrite, DBG_INFO
DebugOut "DebugLevel = " &amp; DebugLevel, DBG_INFO
DebugOut "DebugTest = " &amp; DebugTest, DBG_INFO
End Sub

'****************************************************************

Sub CreateLogFile(TargetComputer)
Dim sMessage, sMPVersion
Dim currentDate, diffDays, baseName, extName, logFolder
Dim FileDate, thisLine, thisLineLen

If DebugFile = true Then
lineCounter = 0

sMessage = "********** " &amp; TargetComputer &amp; ": Start logging script: " &amp; LogFilePath &amp; " ** " &amp; Time() &amp; " **********"
sMPVersion = "MP Version: *** " &amp; MPVERSION &amp; " ***"

On Error Resume Next

If Not oFSO.FolderExists(LogFileDir) Then
oFSO.CreateFolder(LogFileDir)
End If

If oFSO.FolderExists(LogFileDir) Then
If oFSO.FileExists(LogFilePath) Then
'*** read file date (file properties do not work properly)
Set oLogStream = oFSO.OpenTextFile(LogFilePath, 1, True) ' 1 = read
Do While Not oLogStream.AtEndOfStream
thisLine = oLogStream.ReadLine
If InStr(thisLine, "SYSTEMDRIVE") &gt; 0 Then
thisLineLen = Len(thisLine)
thisLine = Right(thisLine, thisLineLen - 4)
thisLine = Left(thisLine, InStr(thisLine, "SYSTEMDRIVE") - 3)
fileDate = CDate(thisLine)
Exit Do
End If
Loop
oLogStream.Close

currentDate = Now()
diffDays = DateDiff("d", fileDate, currentDate)
logFolder = Year(currentDate) &amp; Right("00" &amp; Month(currentDate), 2) &amp; Right("00" &amp; Day(currentDate), 2)

Set oLogStream = oFSO.OpenTextFile(LogFilePath, 8, True) ' 8 = append
oLogStream.WriteLine ""

If CLng(diffDays) &gt;= CLng(DBG_LOGDAYSOLD) Then
baseName = oFSO.GetBaseName(LogFilePath)
extName = oFSO.GetExtensionName(LogFilePath)
DebugOut "Log file '" &amp; baseName &amp; "' is " &amp; diffDays &amp; " days old, older than " &amp; DBG_LOGDAYSOLD &amp; " days. Move to folder '" &amp; logFolder &amp; "'.", DBG_INFO
If Not oFSO.FolderExists(LogFileDir &amp; "\" &amp; logFolder) Then
oFSO.CreateFolder(LogFileDir &amp; "\" &amp; logFolder)
End If
oLogStream.Close
'Use copy &amp; delete, as move fails when a file already esists
oFSO.CopyFile LogFilePath, LogFileDir &amp; "\" &amp; logFolder &amp; "\" &amp; baseName &amp; "." &amp; extName, True
oFSO.DeleteFile LogFilePath, True
Else
oLogStream.Close
End If
End If

If DebugOverWrite = true Then
Set oLogStream = oFSO.OpenTextFile(LogFilePath, 2, True) ' 2 = open new for writing
Else
Set oLogStream = oFSO.OpenTextFile(LogFilePath, 8, True) ' 8 = append
oLogStream.WriteLine ""
End If

lineCounter = lineCounter + 1
oLogStream.WriteLine "[" &amp; lineCounter &amp; "] " &amp; sMessage

lineCounter = lineCounter + 1
oLogStream.WriteLine "[" &amp; lineCounter &amp; "] " &amp; sMPVersion

Else
' if we come here, the discovery script may have been run by hand without running the server discovery:
If DebugMode = true Then
DebugOut "Warning: LogFileDirectory could not be created - 'DebugFile' is turned OFF!", DBG_ALL
End If
DebugFile = false
End If

On Error Goto 0

End If
End Sub


'****************************************************************

Sub GetLogFileIni(FilePathName, Section, Component)
Dim thisVal

On Error Resume Next

DebugOut "Get INI file values from '" &amp; FilePathName &amp; "', section '" &amp; Section &amp; "'", DBG_INFO
If oFSO.FileExists(FilePathName) Then
DebugOut "IniFile [" &amp; FilePathName &amp; "]", DBG_INFO

thisVal = GetIniValue(FilePathName, Section, "DebugMode" &amp; Component)
DebugMode = false
DebugFile = false
If thisVal = "YES" Or thisVal = "TRUE" Or thisVal = "1" Then
DebugMode = true
DebugFile = true
End If
DebugOut "DebugMode = " &amp; DebugMode, DBG_INFO

thisVal = GetIniValue(FilePathName, Section, "OverWrite")
DebugOverWrite = True
If thisVal = "NO" Or thisVal = "FALSE" Or thisVal = "0" Then
DebugOverWrite = false
End If
DebugOut "DebugOverWrite = " &amp; DebugOverWrite, DBG_INFO

thisVal = GetIniValue(FilePathName, Section, "DebugLevel")
If (DebugLevel = "" Or DebugLevel = 0) And thisVal &lt;&gt; "" Then
DebugLevel = thisVal
End If
DebugOut "DebugLevel = " &amp; DebugLevel, DBG_INFO

thisVal = GetIniValue(FilePathName, Section, "DebugTest")
If DebugTest = "" And thisVal &lt;&gt; "" Then
DebugTest = thisVal
End If
DebugOut "DebugTest = " &amp; DebugTest, DBG_INFO
Else
DebugOut "INI file '" &amp; FilePathName &amp; "' does not exist.", DBG_INFO
End If

On Error Goto 0
End Sub

'****************************************************************

Function GetIniValue(FilePathName, Section, KeyValue)
Dim thisLine, thisVal
Dim pos
Dim IniFile

On Error Resume Next

thisVal = ""

'*** open ini file for reading
Set IniFile = oFSO.OpenTextFile(FilePathName, 1) ' 1 = for reading

'*** loop over whole file
Do While Not IniFile.AtEndOfStream
thisLine = Trim(UCase(IniFile.ReadLine))

'*** check if it is a section
If Left(thisLine, 1) = "[" Then
'*** Is this the section we are looking for?
If InStr(thisLine, UCase(Section)) &gt; 0 Then
If Not IniFile.AtEndOfStream Then
thisLine = Trim(UCase(IniFile.ReadLine))
End If

'Loop through the lines of the section
Do While Left(thisLine, 1) &lt;&gt; "["
'*** has line the value we are looking for?
If InStr(thisLine, UCase(KeyValue)) &gt; 0 Then
pos = InStr(thisLine, "=")
If pos &gt; 0 Then
thisVal = Trim(Mid(thisLine, pos+1))
Exit Do
End If
End If

If Not IniFile.AtEndOfStream Then
thisLine = Trim(UCase(IniFile.ReadLine))
Else
Exit Do
End If
Loop
End If
End If
Loop

IniFile.close

GetIniValue = thisVal
End Function

'****************************************************************

Sub DebugOut(Text, Level)
Dim sMessage

If Level And DebugLevel Then 'bitwise logic
If DebugMode = true Then
sMessage = Text
WScript.Echo sMessage
End If

If DebugFile = true And isObject(oLogStream) Then
lineCounter = lineCounter + 1
sMessage = "[" &amp; lineCounter &amp; "] " &amp; Date() &amp; " " &amp; Time() &amp; ": " &amp; Text

On Error Resume Next

oLogStream.WriteLine sMessage

On Error Goto 0
End If
End If
End Sub

'****************************************************************
'****************************************************************
'****************************************************************

'-------------------------------------------------------------------
' Utils.vbs
'-------------------------------------------------------------------

Const HKEY_LOCAL_MACHINE = &amp;H80000002

' the following are fixed entries from the registry - DO NOT CHANGE!
Const regRootSVUUIDPath = "SYSTEM\CurrentControlSet\Control\UUID\C3681B60-0D26-11D3-8319-00A0C9B61E25"
Const regRootSVAgentsPathname = "ServerView SNMP Agents"
Const SVAgentsPathname = "Pathname"
Dim SVAgentName, SVAgentOverallState, SVAgentVersionString
SVAgentName = "ServerView Agents"
SVAgentOverallState = "ServerView Health State"
SVAgentVersionString = SVAgentName &amp; " Version"
Dim SVRaidName, SVRaidOverallState, SVRaidVersionString
SVRaidName = "ServerView RAID"
SVRaidOverallState = "ServerView RAID OverallState"
SVRaidVersionString = "ServerView RAID Version"
Dim SVCommunicationMonitor, SVCommunication
SVCommunicationMonitor = "Communication Monitor"
SVCommunication = "CommunicationMonitor"

Const SVISCOMregPath = "SOFTWARE\Fujitsu\ServerView Suite\SCOM Integration\SVISCOM-Win\PYServerData"

'-----------------------------------

Dim Cabinet, SVAgentRunning, SVAgentVersion, SVASRunning
SVAgentVersion = "0.0.0.00"

Dim CabinetArray
CabinetArray = Array("-1","","","","","")

'-----------------------------------

Dim Registry

'-----------------------------------

'****************************************************************

Function GetSVAgentPath()
Dim SVAgentsPath, regSVAgentsPath

On Error Resume Next

Err.Clear()
Registry.GetStringValue HKEY_LOCAL_MACHINE, regRootSVUUIDPath, regRootSVAgentsPathname, regSVAgentsPath
If Err.Number &lt;&gt; 0 Or IsNull(regSVAgentsPath) Then
SVAgentsPath = ""
DebugOut "Registry Root SV-Agents Path not found", DBG_INFO
Else
DebugOut "regRootSV-Agents Path: " &amp; regSVAgentsPath, DBG_INFO
regSVAgentsPath = regSVAgentsPath &amp; "\STATUS_MIB\CurrentVersion"
Err.Clear()
Registry.GetStringValue HKEY_LOCAL_MACHINE, regSVAgentsPath, SVAgentsPathname, SVAgentsPath
If Err.Number &lt;&gt; 0 Or IsNull(SVAgentsPath) Then
SVAgentsPath = ""
End If
End If

On Error Goto 0

DebugOut "SV-Agents Path: " &amp; SVAgentsPath, DBG_INFO

GetSVAgentPath = SVAgentsPath
End Function

'****************************************************************

Function GetSVAgentVersion()
Dim pos, Agentversion

AgentVersion = GetScciData(&amp;HC00, &amp;HA806, 0, -1)
pos = InStrRev(AgentVersion, ".")
AgentVersion = Left(AgentVersion, pos-1)

DebugOut "SV-Agent Version: " &amp; AgentVersion, DBG_INFO

GetSVAgentVersion = AgentVersion
End Function

'****************************************************************

Function IsSVAgentRunning(TargetComputer)
Dim Services, Service, SVAgentState
Dim sQuery
Dim wbemFlagReturnWhenComplete: wbemFlagReturnWhenComplete = 0

DebugOut "Check running ServerView Agent via WMI", DBG_INFO

' make sure ExecQuery is executed synchronously
sQuery = "SELECT * FROM Win32_Service WHERE Name = 'SrvCtrl'"
DebugOut "WMIQuery: TargetComputer=. Namespace=" &amp; cimv2NS &amp; " Query=" &amp; sQuery, DBG_DATA
Set Services = GetObject("winmgmts:\\." &amp; cimv2NS).ExecQuery(sQuery, "WQL", wbemFlagReturnWhenComplete)

SVAgentState = false

On Error Resume Next
For Each Service in Services
If Service.Name = "SrvCtrl" Then
DebugOut Service.DisplayName &amp; " (" &amp; Service.Name &amp; "): " &amp; Service.State &amp; " / " &amp; Service.Status &amp; " / " &amp; Service.Started, DBG_INFO
If Service.State = "Running" Then
SVAgentState = true
End If
DebugOut cimv2NS &amp; ":" &amp; "Win32_Service" &amp; ".Name: " &amp; Service.Name, DBG_DESC
DebugOut cimv2NS &amp; ":" &amp; "Win32_Service" &amp; ".DisplayName: " &amp; Service.DisplayName, DBG_DESC
DebugOut cimv2NS &amp; ":" &amp; "Win32_Service" &amp; ".State: " &amp; Service.State, DBG_DESC
Exit For
End If
Next
On Error Goto 0

DebugOut "ServerView Agent Service found running = " &amp; SVAgentState, DBG_INFO

IsSVAgentRunning = SVAgentState
End Function

'****************************************************************

Function GetSVRaidVersion()
Const regRaidVersion = "Version"

Dim i, RaidVersion, RaidRegistryList

RaidRegistryList = Array (_
"SOFTWARE\Fujitsu Siemens Computers\ServerView RAID", _
"SOFTWARE\Fujitsu\ServerView RAID", _
"SOFTWARE\Wow6432Node\Fujitsu Siemens Computers\ServerView RAID", _
"SOFTWARE\Wow6432Node\Fujitsu\ServerView RAID")

RaidVersion = ""

On Error Resume Next

For each i in RaidRegistryList
Err.Clear()
Registry.GetStringValue HKEY_LOCAL_MACHINE, i, regRaidVersion, RaidVersion
If Err.Number = 0 And Len(RaidVersion) &gt; 0 Then
Exit For
Else
RaidVersion = ""
End If
Next

On Error Goto 0

If Len(RaidVersion) &gt; 0 Then
DebugOut "ServerView RAID Version: " &amp; RaidVersion, DBG_INFO
Else
DebugOut "ServerView RAID NOT installed", DBG_INFO
End If

GetSVRaidVersion = RaidVersion
End Function

'****************************************************************

Function CabinetByteArrayToString(byteArray)
Dim i, bLen

If VarType(byteArray) &lt; 2 Then
Exit Function
Else
bLen = lenb(bytearray)

ReDim Inverse(bLen)
ReDim Direct(bLen-1)

' Evaluate CabinetByteArray
For i=1 to bLen
Direct(i-1) = right("0" &amp; hex(AscB(MidB(byteArray,i,1))),2)
Next

' Inverse for Cabinet ID Evaluation
For i=1 to bLen
Inverse(i) = Direct(bLen - i)
Next
End If

DebugOut "HexString: " &amp; Join(Inverse," "), DBG_DATA
CabinetByteArrayToString = Join(Inverse,"")
End Function

'****************************************************************

Function CabinetLongToString(wordStruct)
Const maxNum = 9007199254740991
Const HexChars = "0123456789ABCDEF"
Dim HexString

If wordStruct = 0 Then
WordStructToString = "0"
Exit Function
End If

If wordStruct &gt; CDbl(maxNum) Then
WordStructToString = Empty
Exit Function
End If

Do While wordStruct &gt; 0
HexString = Mid(HexChars, 1 + (wordStruct - 16 * Fix(wordStruct / 16)), 1) &amp; HexString
wordStruct = Fix(wordStruct/16)
Loop

DebugOut "HexString: " &amp; HexString, DBG_DATA
CabinetLongToString = HexString
End Function

'****************************************************************

Function GetPYServerData(strValueName)
Dim strValue
strValue = ""

On Error Resume Next
Err.Clear()

Registry.GetStringValue HKEY_LOCAL_MACHINE, SVISCOMregPath, strValueName, strValue
If Err.Number &lt;&gt; 0 Or IsNull(strValue) Then
strValue = ""
Err.Clear()
End If

On Error Goto 0

DebugOut "GetPYServerData: " &amp; strValueName &amp; ": '" &amp; strValue &amp; "'", DBG_INFO

GetPYServerData = strValue
End Function

'****************************************************************

Function SavePYServerData(strValueName, strValue)
Dim RetVal, regPath, ErrorNumber

regPath = SVISCOMregPath

On Error Resume Next

Err.Clear()
SavePYServerData = 0
RetVal = Registry.CreateKey(HKEY_LOCAL_MACHINE, regPath)
If (RetVal = 0) And (Err.Number = 0) Then
Err.Clear()
RetVal = Registry.SetStringValue(HKEY_LOCAL_MACHINE, regPath, strValueName, strValue)
ErrorNumber = Err.Number
If (RetVal &lt;&gt; 0) Then
DebugOut "Error on writing " &amp; strValueName &amp; ": RetVal " &amp; RetVal, DBG_INFO
ElseIf (ErrorNumber &lt;&gt; 0) Then
DebugOut "Error on writing " &amp; strValueName &amp; ": ErrorNumber" &amp; ErrorNumber, DBG_INFO
Else
DebugOut strValueName &amp; ": '" &amp; strValue &amp; "' saved", DBG_INFO
SavePYServerData = strValue
End If
Else
DebugOut "Error on creating RegPath '" &amp; regPath &amp; "'", DBG_INFO
End If

On Error Goto 0

End Function

'****************************************************************

Sub DeletePYServerData(strValueName)
Dim strValue

strValue = ""

On Error Resume Next

Err.Clear()

Registry.GetStringValue HKEY_LOCAL_MACHINE, SVISCOMregPath, strValueName, strValue
If Not IsNull(strValue) Then
DebugOut "DeletePYServerData: Delete '" &amp; strValueName &amp; "' from PYServerData", DBG_INFO
Registry.DeleteValue HKEY_LOCAL_MACHINE, SVISCOMregPath, strValueName
Else
DebugOut "DeletePYServerData: Registry value '" &amp; strValueName &amp; "' does not exist.", DBG_INFO
End If

On Error Goto 0
End Sub

'****************************************************************

Function ConvertToMatchingUnit(Value)

Dim SizeUnit
Dim TotalLocalUnit
Dim newUnitLimit

newUnitLimit = 1023

On Error Resume Next

If Value = 0 Then
TotalLocalUnit = 0
SizeUnit = " Bytes"
Else
' Start with Megabytes
SizeUnit = " MB"
TotalLocalUnit = CLng(Value / (1024 * 1024))
If TotalLocalUnit &gt; newUnitLimit Then
' Gigabytes
SizeUnit = " GB"
TotalLocalUnit = CLng(TotalLocalUnit / 10.24)
TotalLocalUnit = TotalLocalUnit / 100
If TotalLocalUnit &gt; newUnitLimit Then
' avoid error on rounding
TotalLocalUnit = Value / (1024 * 1024 * 1024)
' Terabytes
SizeUnit = " TB"
TotalLocalUnit = CLng(TotalLocalUnit / 10.24)
TotalLocalUnit = TotalLocalUnit / 100
If TotalLocalUnit &gt; newUnitLimit Then
' avoid error on rounding
TotalLocalUnit = Value / (1024 * 1024 * 1024 * 1024)
' Petabytes
SizeUnit = " PB"
TotalLocalUnit = CLng(TotalLocalUnit / 10.24)
TotalLocalUnit = TotalLocalUnit / 100
If TotalLocalUnit &gt; newUnitLimit Then
' avoid error on rounding
TotalLocalUnit = Value / (1024 * 1024 * 1024 * 1024 * 1024)
' Exabytes
SizeUnit = " EB"
TotalLocalUnit = CLng(TotalLocalUnit / 10.24)
TotalLocalUnit = TotalLocalUnit / 100
End If
End If
End If
End If
End If

ConvertToMatchingUnit = TotalLocalUnit &amp; SizeUnit

DebugOut "Converted " &amp; Value &amp; " to '" &amp; TotalLocalUnit &amp; SizeUnit &amp; "'", DBG_INFO

On Error Goto 0

End Function

'****************************************************************

Function SVhasCIMProvider(SVAgentVersion)
Const regMSCurrentVersion = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
Dim hasProvider
Dim WindowsVersion

' ServerView CIM Providers need
' - agents version SVCIMVERSION_MIN or higher
' - Windows Server 2008 R2 (6.1) or Windows Server 2012 (6.2)

Registry.GetStringValue HKEY_LOCAL_MACHINE, regMSCurrentVersion, "CurrentVersion", WindowsVersion

hasProvider = false

If SVAgentVersion &gt;= SVCIMVERSION_MIN Then
If WindowsVersion &gt; "6.0" Then
hasProvider = true
End If
End If

'DebugOut "SVhasCIMProvider = " &amp; hasProvider, DBG_INFO

SVhasCIMProvider = hasProvider
End Function

'****************************************************************
'****************************************************************
'****************************************************************


'-------------------------------------------------------------------
' PRIMERGYServerDiscoveryComplete.vbs
' $MPElement$
' $Target/Id$
' $Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$
' $Target/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$
' Summary:
' Discover Fujitsu PRIMERGY Server.
'-------------------------------------------------------------------

Const MPScript = "PRIMERGYServerDiscovery.vbs"

Dim insideMP
insideMP = true 'script runs inside MP
'insideMP = false 'only for test outside MP

Dim devProperty1, devProperty2, devProperty3, devProperty4, devProperty5
ReDim devProperty1(cMAXINDEX)
ReDim devProperty2(cMAXINDEX)
ReDim devProperty3(cMAXINDEX)
ReDim devProperty4(cMAXINDEX)
ReDim devProperty5(cMAXINDEX)

Const SectionIni = "ServerDiscovery"
Const LogFileName = "\PRIMERGYServerDiscoveryTrace_"

'-----------------------------------

Sub Main()
Dim oArgs, oDiscoveryData, oDiscoveryEmptyData, oInst, oServer, oRelationship, serverClass
Dim colItems, objItem, WMIVersion
Dim SourceType, SourceID, ManagedEntityId, PrincipalName, TargetComputer, NetworkName
Dim ManufacturerShort, Manufacturer, FTSServerName, ModelName, ChassisModel, ChassisModelShort
Dim netServerName, OSServerName, OSName, OSVersion
Dim SavedManufacturer, SavedModelName
Dim SerialNumber, ChassisID, ModelNamePRIMERGY, ModelNamePRIMERGYModelGroup
Dim Cabinets, cabData, cabString
Dim componentSubSystemType
Dim intComponentValue, strComponentValue, cabID, devID
Dim devType(50), devNo(50)
Dim SCCIIndex, index, i, j
Dim totalMemory, totalMemoryUnit, totalDiskSpace
Dim SVRaidVersion
Dim SVAgentPath, SVAgentClass, SVNamespace, SCOMAgentVersion, MonitoringAgents, RaidManager
Dim SystemFirmware, BIOSVersion
Dim iRMCName, BMCIPv4Addr, BMCIPv6Addr, iRMCDNSName, IPAddress
Dim CIMProvider, ret

Set oArgs = WScript.Arguments

If insideMP = true And oArgs.Count &lt; 4 Then
DebugOut "Not enough arguments -&gt; Server discovery script exits with error!", DBG_INFO
WScript.Quit -1
End If

SourceId = oArgs(0)
ManagedEntityId = oArgs(1)
PrincipalName = oArgs(2)
TargetComputer = oArgs(3)
If oArgs.Count &gt; 4 Then
If IsNumeric(oArgs(4)) Then
DebugLevel = CInt(oArgs(4))
If oArgs.Count &gt; 5 Then DebugTest = oArgs(5) End If
Else
DebugOut "!!", DBG_INFO
DebugOut "!! Ignoring all debug options! Use: ... &lt;DebugLevel&gt; &lt;DebugTest&gt;", DBG_INFO
DebugOut "!!", DBG_INFO
End If
End If
DebugOut "Args: " &amp; SourceId &amp; " " &amp; ManagedEntityId &amp; " " &amp; PrincipalName &amp; " " &amp; TargetComputer &amp; " " &amp; DebugLevel &amp; " " &amp; DebugTest, DBG_INFO

' Shell object for system access
Set oFSO = CreateObject("Scripting.FileSystemObject")

PrepareLogging TargetComputer, LogFileName, SectionIni, ""
DebugOut "Server Discovery Version is: *** " &amp; MPVERSION &amp; " ***", DBG_ALL

' move all files from old log folder to new log folder
On Error Resume Next
If Not oFSO.FolderExists(LogFileDir) Then
If Not oFSO.FolderExists(LogFileDirBase) Then oFSO.CreateFolder(LogFileDirBase) End If
oFSO.CreateFolder(LogFileDir)

Dim FileCollection, LogFolderOld, File
Set LogFolderOld = oFSO.GetFolder(LogFileDirBase)
Set FileCollection = LogFolderOld.Files
For Each File in FileCollection
'Use copy &amp; delete, as move fails when a file already esists
oFSO.CopyFile File, LogFileDir &amp; "\" &amp; File.Name, True
oFSO.DeleteFile File, True
Next
End If
On Error Goto 0

If insideMP = true Then
SourceType = 0
On Error Resume Next
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oDiscoveryData = oAPI.CreateDiscoveryData(SourceType, SourceId, ManagedEntityId)
Set oDiscoveryEmptyData = oAPI.CreateDiscoveryData(SourceType, SourceId, ManagedEntityId)
On Error Goto 0
If Not isObject(oAPI) Then insideMP = false End If
End If

' initialize Registry
On Error Resume Next
Set Registry = GetObject("winmgmts:{impersonationLevel=impersonate}\\.\root\default:StdRegProv")
If IsEmpty(Registry) Or Err.Number &lt;&gt; 0 Then
DebugOut "#############", DBG_INFO
DebugOut "############# Cannot access WMI on PRIMERGY Server " &amp; TargetComputer &amp; "!", DBG_INFO
DebugOut "#############", DBG_INFO
LogScriptEvent 110, ERROR_EVENT, "Unable to connect to WMI: /root/default:StdRegProv. Check if the WMI service is enabled on " &amp; TargetComputer &amp; "."
Else
DebugOut "Access to registry via WMI initialised.", DBG_INFO
WMIVersion = GetWMIVersion(TargetComputer)
End If
On Error Goto 0

CreateLogIniFile(LogFileDir) '*** create the Log Ini File "&lt;TEMP&gt;\SVISCOMLog.in_" (if not available)

' SVAgents
'-----------------------------------
SVAgentPath = GetSVAgentPath()

If Len(SVAgentPath) = 0 Then
DebugOut "#############", DBG_INFO
DebugOut "############# ServerView Agent is not installed on PRIMERGY Server " &amp; TargetComputer &amp; "!", DBG_INFO
DebugOut "############# Quit.", DBG_INFO
DebugOut "#############", DBG_INFO
If insideMP = true Then
Call oAPI.Return(oDiscoveryEmptyData)
If DebugMode = True Then WScript.Echo "" End If
End If
WScript.Quit(0)
End If

SVAgentRunning = IsSVAgentRunning(TargetComputer)

If SVAgentRunning = false Then
DebugOut "#############", DBG_INFO
DebugOut "############# ServerView Agent is not running on PRIMERGY Server " &amp; TargetComputer &amp; "!", DBG_INFO
DebugOut "#############", DBG_INFO
Else
On Error Resume Next
Set oSwitch = WScript.CreateObject("RSwitch.RSwitch.1")
If IsObject(oSwitch) = false Then
WScript.Sleep SCCISLEEPTIME
Set oSwitch = WScript.CreateObject("RSwitch.RSwitch.1")
End If

If IsObject(oSwitch) = true Then
'*** give a hint to agents, who accesses them (in case of DEBUG / trace)
oSwitch.ClientName = "SVISCOM.vbs"

' request ServerView Agent version to check whether SCCI is possible
' Note: ServerView Agentless service seems to indicate ServerView Agents running but does not support SCCI
MonitoringAgents = "N/A"
SVAgentVersion = oSwitch.VBRequest(&amp;HC00, &amp;HA806, 0, -1, 0, 0, 0, ret)
if ret &lt;&gt; 0 Then
DebugOut "oSwitch: No Data for opCode=0x" &amp; Hex(&amp;HC00) &amp; " opCodeExt=0x" &amp; Hex(&amp;HA806) &amp; " objIndex=" &amp; 0 &amp; " cabID=" &amp; -1, DBG_DESC
DebugOut "#############", DBG_INFO
DebugOut "############# ServerView SCCI not supported " &amp; TargetComputer &amp; "!", DBG_INFO
DebugOut "#############", DBG_INFO
oSwitch = Null
SVAgentRunning = false
SVASRunning = true
Else
DebugOut "oSwitch: opCode=0x" &amp; Hex(&amp;HC00) &amp; " opCodeExt=0x" &amp; Hex(&amp;HA806) &amp; " objIndex=" &amp; 0 &amp; " cabID=" &amp; -1 &amp; " -&gt; scciValue = '" &amp; SVAgentVersion &amp; "'", DBG_DESC
SVAgentVersion = GetSVAgentVersion()
MonitoringAgents = SVAgentName &amp; " V" &amp; SVAgentVersion

If Len(SVAgentVersion) = 0 Or SVAgentVersion &lt; SVAGENTVERSION_MIN Then
LogScriptEvent 111, WARNING_EVENT, "ServerView Agent Version V" &amp; SVAgentVersion &amp; " too old! Use at least V" &amp; SVAGENTVERSION_MIN &amp; "!"
End If

SVASRunning = false
End If
End If
On Error Goto 0
End If

If SVASRunning = true Then
DebugOut "**** ServerView Agentless Service is running. *** Quit. ****", DBG_ALL
If insideMP = true Then
Call oAPI.Return(oDiscoveryEmptyData)
If DebugMode = True Then WScript.Echo "" End If
End If
WScript.Quit(0)
End If

CIMProvider = SVhasCIMProvider(SVAgentVersion)
DebugOut "This system has CIMProvider = " &amp; CIMProvider, DBG_INFO

' check whether the script was forced to CIM/SCCI
If DebugTest &lt;&gt; "" Then
If Not StrComp(DebugTest, "SCCI", 1) Then
CIMProvider = False
Else
CIMProvider = True
End If
End If
DebugOut "This system has CIMProvider = " &amp; CIMProvider, DBG_INFO

If CIMProvider = False Then SVNamespace = cimv2NS End If
If CIMProvider = True Then SVNamespace = svsNS End If

If SVAgentRunning = true Then
Cabinet = GetScciData(&amp;HE204, &amp;H0, &amp;H0, -1)
DebugOut "Main Cabinet ID = " &amp; Cabinet, DBG_INFO
End If


' Determine Cabinet Number(s) for SCCI
'--------------------------------------------------------------
If SVAgentRunning = true Then
i = GetScciData(&amp;H0C00, &amp;H0108, 0, Cabinet)
Cabinets = "Main: " &amp; Cabinet &amp; " (" &amp; i &amp; ")"

CabinetArray(0) = CInt(Cabinet)
cabData = GetScciData(&amp;H0220, 0, 0, Cabinet)

If VarType(cabData) = 2 Or VarType(cabData) = 3 Then
cabString = CabinetLongToString(cabData)
Else
cabString = CabinetByteArrayToString(cabData)
End If

index = 1
Do While cabString &lt;&gt; ""
cabData = Right(cabString, 4)
CabinetArray(index) = CInt("&amp;H" &amp; cabData)
cabString = Replace(cabString, cabData, "")
index = index + 1
Loop
If index &gt; 1 Then Cabinets = Cabinets &amp; ", Extension: " End If

index = 0
For Each cabData in CabinetArray
If index &gt; 0 And cabData &lt;&gt; "" Then
i = GetScciData(&amp;H0C00, &amp;H0108, 0, cabData)
DebugOut "CabinetID " &amp; index &amp; ": " &amp; cabData &amp; "(" &amp; i &amp; ")", DBG_DATA
Cabinets = Cabinets &amp; ", " &amp; cabData &amp; " (" &amp; i &amp; ")"
End If
index = index + 1
Next
End If
DebugOut "Cabinets: [" &amp; Cabinets &amp; "]", DBG_INFO


' ***** start Server Discovery ****
'-------------------------------------------------
SavedModelName = GetPYServerData("ModelName")
SavedManufacturer = GetPYServerData("Manufacturer")

ManufacturerShort = ""
Manufacturer = ""
ModelName = ""
ChassisModel = ""
SerialNumber = ""
totalMemoryUnit = 0
totalMemory = 0

' do not create an error message here (last arg = 'False') in case this is not a FUJITSU system!
If CIMProvider = True Then
SVAgentClass = "SVS_PGYChassis"
Set colItems = WMIQuery(TargetComputer, SVNamespace, "SELECT * FROM " &amp; SVAgentClass, False)

If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem in colItems
' Check that we really get our cabinet (relevant for BX and CX)
If CInt("&amp;H" &amp; objItem.Tag) = CInt(Cabinet) Then
Manufacturer = objItem.Manufacturer
ModelName = objItem.Model
ChassisModel = objItem.Name
SerialNumber = objItem.SerialNumber
End If
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".Tag: " &amp; objItem.Tag, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".Manufacturer: " &amp; objItem.Manufacturer, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".Model: " &amp; objItem.Model, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".Name: " &amp; objItem.Name, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".SerialNumber: " &amp; objItem.SerialNumber, DBG_DESC
Next
On Error Goto 0
End If
Else
If SVAgentRunning = true Then
Manufacturer = GetScciData(&amp;HC00, &amp;H150A, &amp;H0, Cabinet)
ModelName = GetScciData(&amp;HC00, &amp;H608, &amp;H0, Cabinet)
SerialNumber = GetScciData(&amp;HC00, &amp;H600, &amp;H0, Cabinet)
ChassisModel = GetScciData(&amp;HC00, &amp;H108, &amp;H0, Cabinet)
End If
End If

' If Agents are not running but the Seed Discovery found that this is a Fujitsu server
' (we would not be here otherwise), let's try to find out who we are
' start with PYServerData
If SVAgentRunning = false Then
Manufacturer = SavedManufacturer
ModelName = SavedModelName
ChassisModel = GetPYServerData("ChassisModel")
SerialNumber = GetPYServerData("SerialNumber")
End If

ModelNamePRIMERGYModelGroup = UCase(Left(ModelName, 11))
ModelNamePRIMERGY = UCase(Left(ModelName, 8))
ChassisModelShort = Left(ChassisModel, 7)
ChassisID = "N/A"

DebugOut "Manufacturer: [" &amp; Manufacturer &amp; "]", DBG_INFO
DebugOut "Model Name: [" &amp; ModelName &amp; "]", DBG_INFO
DebugOut "Chassis Model: [" &amp; ChassisModel &amp; "]", DBG_INFO
DebugOut "Chassis Model Short: [" &amp; ChassisModelShort &amp; "]", DBG_INFO
DebugOut "Serial Number: [" &amp; SerialNumber &amp; "]", DBG_INFO
DebugOut "Model Name PRIMERGY: [" &amp; ModelNamePRIMERGY &amp; "]", DBG_INFO
DebugOut "PRIMERGY Model Group: [" &amp; ModelNamePRIMERGYModelGroup &amp; "]", DBG_INFO


' Calculate the total memory size using CIM_PhysicalMemory
'-------------------------------------------------
' totalMemory must be taken from CIM_PhysicalMemory, as Win32_ComputerSystem gives 'memory avail to OS'
SVAgentClass = "CIM_PhysicalMemory"
Set colItems = WMIQuery(TargetComputer, cimv2NS, "SELECT * FROM " &amp; SVAgentClass, True)

totalMemory = 0
If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem in colItems
DebugOut "Memory size (module): " &amp; objItem.Capacity, DBG_INFO
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".Capacity: " &amp; objItem.Capacity, DBG_DESC
If objItem.Capacity &gt; 0 Then totalMemory = totalMemory + objItem.Capacity End If
Next
On Error Goto 0
End If

DebugOut "Memory size (overall): " &amp; totalMemory, DBG_INFO
totalMemoryUnit = ConvertToMatchingUnit(totalMemory)
DebugOut "Memory size (overall): " &amp; totalMemoryUnit, DBG_INFO


'*** Get ServerName from Win32_ComputerSystem
'-------------------------------------------------
SVAgentClass = "Win32_ComputerSystem"
Set colItems = WMIQuery(TargetComputer, cimv2NS, "SELECT * FROM " &amp; SVAgentClass, True)

If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem in colItems
FTSServerName = objItem.Name
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".Name: " &amp; objItem.Name, DBG_DESC
DebugOut "ServerName: [" &amp; FTSServerName &amp; "]", DBG_INFO
Next
On Error Goto 0
End If

' Get OS Name from Win32_OperatingSystem
'-------------------------------------------------
OSName = ""
OSVersion = ""
OSServerName = ""

SVAgentClass = "Win32_OperatingSystem"
Set colItems = WMIQuery(TargetComputer, cimv2NS, "SELECT * FROM " &amp; SVAgentClass, True)

If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem in colItems
OSName = objItem.Caption
OSVersion = objItem.Version
OSServerName = objItem.CSName
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".Caption: " &amp; objItem.Caption, DBG_DESC
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".Version: " &amp; objItem.Version, DBG_DESC
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".CSName: " &amp; objItem.CSName, DBG_DESC
Next
On Error Goto 0
End If
DebugOut "OSName: " &amp; OSName, DBG_INFO
DebugOut "OSVersion: " &amp; OSVersion, DBG_INFO
DebugOut "OSServerName: " &amp; OSServerName, DBG_INFO

If Len(FTSServerName) = 0 Then
If Len(OSServerName) = 0 Then
' yet another try: the network name ...
On Error Resume Next

Dim objNetwork
Set objNetwork = WScript.CreateObject("WScript.Network")
netServerName = objNetwork.ComputerName
DebugOut "OS-NetworkName: " &amp; netServerName, DBG_INFO

If IsNull(netServerName) = FALSE And Len(netServerName) &gt; 0 Then
FTSServerName = netServerName
End If

On Error Goto 0
Else
FTSServerName = OSServerName
End If
End If


' Check the PRIMERGY model using Win32_ComputerSystemProduct
'--------------------------------------------------------
' In case we did not get Manufacturer and ModelName from FTS classes, try Win32_ComputerSystemProduct
If Len(Manufacturer) = 0 Or Len(ModelName) = 0 Then
SVAgentClass = "Win32_ComputerSystemProduct"
Set colItems = WMIQuery(TargetComputer, cimv2Ns, "SELECT * FROM " &amp; SVAgentClass, True)

If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem in colItems
If Len(Manufacturer) = 0 Then
Manufacturer = objItem.Vendor
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".Vendor: " &amp; objItem.Vendor, DBG_DESC
DebugOut "Manufacturer: [" &amp; Manufacturer &amp; "]", DBG_INFO
End If

If Len(ModelName) = 0 Then
ModelName = objItem.Name
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".Name: " &amp; objItem.Name, DBG_DESC
ModelNamePRIMERGYModelGroup = UCase(Left(objItem.Name, 11))
ModelNamePRIMERGY = UCase(Left(objItem.Name, 8))

DebugOut "ModelName: [" &amp; ModelName &amp; "]", DBG_INFO
DebugOut "ModelNamePRIMERGY: [" &amp; ModelNamePRIMERGY &amp; "]", DBG_INFO
DebugOut "ModelNamePRIMERGYModelGroup: [" &amp; ModelNamePRIMERGYModelGroup &amp; "]", DBG_INFO
End If

If Len(ChassisModel) = 0 Then
ChassisModel = "Unknown"
End If
Next
On Error Goto 0
End If
End If

'*** check if this is a valid ModelName
If Len(SavedModelName) &gt; 0 And SavedModelName &lt;&gt; ModelName Then
DebugOut "Use saved PY Server data:", DBG_INFO
ModelName = SavedModelName
ModelNamePRIMERGY = UCase(Left(ModelName, 8))
Manufacturer = SavedManufacturer
ModelNamePRIMERGYModelGroup = UCase(Left(ModelName, 11))
ChassisModel = GetPYServerData("ChassisModel")
ChassisModelShort = Left(ChassisModel, 6)

DebugOut "ModelName: [" &amp; ModelName &amp; "]", DBG_INFO
DebugOut "ModelNamePRIMERGY: [" &amp; ModelNamePRIMERGY &amp; "]", DBG_INFO
DebugOut "ModelNamePRIMERGYModelGroup: [" &amp; ModelNamePRIMERGYModelGroup &amp; "]", DBG_INFO
DebugOut "Chassis Model: [" &amp; ChassisModel &amp; "]", DBG_INFO
DebugOut "Manufacturer: [" &amp; Manufacturer &amp; "]", DBG_INFO
End If

ManufacturerShort = UCase(Left(Manufacturer, 7))
DebugOut "ManufacturerShort: [" &amp; Manufacturer &amp; "]", DBG_INFO

serverClass = ""
If ManufacturerShort = "FUJITSU" Or ManufacturerShort = "FSC" Then
DebugOut "ModelNamePRIMERGY: [" &amp; ModelNamePRIMERGY &amp; "]", DBG_INFO
If ModelNamePRIMERGY = "PRIMERGY" Then
DebugOut "ModelNamePRIMERGYModelGroup: [" &amp; ModelNamePRIMERGYModelGroup &amp; "]", DBG_INFO
If ModelNamePRIMERGYModelGroup = "PRIMERGY TX" Or ChassisModelShort = "EC100F" Or ChassisModelShort = "EC200F" Then
DebugOut TargetComputer &amp; " / " &amp; ModelName &amp; " inserted in ModelNamePRIMERGYModelGroup: TX-Model", DBG_INFO
serverClass = "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.TXServer']$"
ElseIf ModelNamePRIMERGYModelGroup = "PRIMERGY CX" Then
DebugOut TargetComputer &amp; " / " &amp; ModelName &amp; " inserted in ModelNamePRIMERGYModelGroup: CX-Model", DBG_INFO
serverClass = "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.CXServer']$"
ElseIf ModelNamePRIMERGYModelGroup = "PRIMERGY RX" Or ChassisModelShort = "EC230R" Then
DebugOut TargetComputer &amp; " / " &amp; ModelName &amp; " inserted in ModelNamePRIMERGYModelGroup: RX-Model", DBG_INFO
serverClass = "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RXServer']$"
ElseIf ModelNamePRIMERGYModelGroup = "PRIMERGY SX" Then
DebugOut TargetComputer &amp; " / " &amp; ModelName &amp; " inserted in ModelNamePRIMERGYModelGroup: SX-Model", DBG_INFO
serverClass = "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.SXServer']$"
ElseIf ModelNamePRIMERGYModelGroup = "PRIMERGY BX" Then
DebugOut TargetComputer &amp; " / " &amp; ModelName &amp; " inserted in ModelNamePRIMERGYModelGroup: BX-Model", DBG_INFO
ChassisID = ChassisModel &amp; "." &amp; SerialNumber
DebugOut "ChassisID: " &amp; ChassisID, DBG_INFO
serverClass = "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.BXServer']$"
Else
'Not an uptodate PRIMERGY model
DebugOut TargetComputer &amp; " / " &amp; ModelName &amp; " inserted in ModelNamePRIMERGYModelGroup: Other PRIMERGY Model", DBG_INFO
serverClass = "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.XXServer']$"
End If
ElseIf ModelNamePRIMERGY = "PRIMEQUE" Then
DebugOut TargetComputer &amp; " / " &amp; ModelName &amp; " inserted in ModelNamePRIMERGYModelGroup: PRIMEQUEST Partition", DBG_INFO
serverClass = "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.PQPartition']$"
Else
'Not a modern PRIMERGY model
DebugOut TargetComputer &amp; " / " &amp; ModelName &amp; " inserted in ModelNamePRIMERGYModelGroup: Other PRIMERGY Model", DBG_INFO
serverClass = "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.XXServer']$"
End If

'*** save ModelName
If Len(SavedModelName) = 0 And Len(ModelName) &gt; 0 Then
Call SavePYServerData("ModelName", ModelName)
Call SavePYServerData("ChassisModel", ChassisModel)
Call SavePYServerData("Manufacturer", Manufacturer)
End If
Call SavePYServerData("OSVersion", OSVersion)

If ModelName = "" Then ModelName = "Unknown" End If
If ChassisModel = "" Then ChassisModel = "Unknown" End If
If ChassisID = "" Then ChassisID = "N/A" End If
If Manufacturer = "" Then Manufacturer = "Fujitsu Technology Solutions" End If

DebugOut "PrincipalName = " &amp; PrincipalName, DBG_INFO
DebugOut "FTSServerName = " &amp; FTSServerName, DBG_INFO
DebugOut "TargetComputer = " &amp; TargetComputer, DBG_INFO
DebugOut "ModelName = " &amp; ModelName, DBG_INFO
DebugOut "ChassisModel = " &amp; ChassisModel, DBG_INFO

' Check PrincipalName (from SCOM) against FTSServerName (from hardware) to eliminate cluster ressources
If insideMP = true Then
'*** does not work with: PrincipalName = "."
If Len(PrincipalName) &gt; 2 Then
Dim Name1, Name2, Name3, Name4, tmpPos

'*** cut off domain name, if it exists
Name1 = Ucase(PrincipalName)
tmpPos = InStr(Name1, ".")
If tmpPos &gt; 1 then
Name3 = Left(Name1, tmpPos-1)
Else
Name3 = Name1
End If

'*** cut off domain name, if it exists
Name2 = Ucase(FTSServerName)
tmpPos = InStr(Name2, ".")
If tmpPos &gt; 1 then
Name4 = Left(Name2, tmpPos-1)
Else
Name4 = Name2
End If

DebugOut "Principal-base = " &amp; Name3, DBG_INFO
DebugOut "FTSServer-base = " &amp; Name4, DBG_INFO

If Name3 &lt;&gt; Name4 Then
'*** FTSServerName is different from PrincipalName!
'*** This is the case e.g. for a cluster resource = NO SERVER!
DebugOut "#############", DBG_INFO
DebugOut "############# PrincipalName (base) &lt;&gt; FTSServerName (base)!", DBG_INFO
DebugOut "############# (base = checked without domain name extension)", DBG_INFO
DebugOut "#############", DBG_INFO
DebugOut "############# This is no SERVER to monitor!", DBG_INFO
DebugOut "#############", DBG_INFO
DebugOut "############# Return empty DISCOVERY data and quit script.", DBG_INFO
DebugOut "#############", DBG_INFO
If insideMP = true Then
Call oAPI.Return(oDiscoveryEmptyData)
If DebugMode = True Then WScript.Echo "" End If
End If
DebugOut "WScript.Quit(0)", DBG_INFO
WScript.Quit(0)
Else
DebugOut "PrincipalName (base) = FTSServerName (base). This is no cluster ressource.", DBG_INFO
End If
Else
DebugOut "#############", DBG_INFO
DebugOut "############# WARNING:", DBG_INFO
DebugOut "#############", DBG_INFO
DebugOut "############# 'insideMP = true' and PrincipalName has two or less characters??????", DBG_INFO
DebugOut "#############", DBG_INFO
End If
End If
Else
DebugOut "**** Not a system of Fujitsu Technology Solutions. *** Quit. ****", DBG_ALL
If insideMP = true Then
Call oAPI.Return(oDiscoveryEmptyData)
If DebugMode = True Then WScript.Echo "" End If
End If
WScript.Quit(0)
End If

' check whether a customer wants to skip Monitoring
ret = GetPYServerData("NoMonitor")
If Not Len(ret) = 0 And StrComp(LCase(ret), "true") = 0 Then
DebugOut "**** Found noMonitor flag in Registry. *** Quit. ****", DBG_ALL
If insideMP = true Then
Call oAPI.Return(oDiscoveryEmptyData)
If DebugMode = True Then WScript.Echo "" End If
End If
WScript.Quit(0)
End If

If Len(serverClass) = 0 Then
If insideMP = true Then
DebugOut "**** Did not get any Discovery Data. *** Quit. ****", DBG_ALL
Call oAPI.Return(oDiscoveryEmptyData)
If DebugMode = True Then WScript.Echo "" End If
End If
WScript.Quit(0) ' got no Discovery Data
End If


' get server IP adress(es)
'---------------------------------------
IPAddress = ""

SVAgentClass = "Win32_NetworkAdapterConfiguration"
Set colItems = WMIQuery(TargetComputer, cimv2NS, "SELECT * FROM " &amp; SVAgentClass &amp; " WHERE MACAddress &gt; ''", False)

index = 0
If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem In colItems
If IsArray(objItem.IPAddress) Then
If IPAddress &lt;&gt; "" Then
IPAddress = IPAddress &amp; ", "
End If
strComponentValue = "IP Address(es) " &amp; index &amp; ": "

For i=0 To UBound(objItem.IPAddress)
If i = 0 Then
If objItem.IPAddress(i) &lt;&gt; "" Then
IPAddress = IPAddress &amp; objItem.IPAddress(i)
strComponentValue = strComponentValue &amp; objItem.IPAddress(i)
End If
End If
If i = 1 Then
If objItem.IPAddress(i) &lt;&gt; "" Then
IPAddress = IPAddress &amp; "/" &amp; objItem.IPAddress(i)
strComponentValue = strComponentValue &amp; " / " &amp; objItem.IPAddress(i)
End If
End If
DebugOut strComponentValue, DBG_INFO
Next
index = index + 1
End If
Next
On Error Goto 0
End If
DebugOut "IP Address: " &amp; IPAddress, DBG_INFO


' calculate total local disk space
'---------------------------------------
Dim TotalLocalDisk, TotalLocalDiskUnit, TotalLocalDiskNo
TotalLocalDisk = 0
TotalLocalDiskNo = 0

' Changed from Win32_LogicalDisk to Win32_DiskDrive as Win32_LogicalDisk fails on servers where
' the RAID controller is configured to SCSI (or some such)
SVAgentClass = "Win32_DiskDrive"
Set colItems = WMIQuery(TargetComputer, cimv2NS, "SELECT * FROM " &amp; SVAgentClass, False)

If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem in colItems
If InStr(objItem.MediaType, "Removable") Then
DebugOut "Skipping removable media '" &amp; objItem.Caption &amp; "'.", DBG_INFO
ElseIf InStr(objItem.MediaType, "External") Then
DebugOut "Skipping external media '" &amp; objItem.Caption &amp; "'.", DBG_INFO
Else
DebugOut "Disk " &amp; objItem.Caption &amp; ", Type " &amp; objItem.MediaType &amp; ", Size: " &amp; objItem.Size, DBG_INFO
If Not (IsNull(objItem.Size) Or Len(objItem.Size) = 0) Then
TotalLocalDisk = TotalLocalDisk + objItem.Size
TotalLocalDiskNo = TotalLocalDiskNo + 1
End If
End If
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".Caption: " &amp; objItem.Caption, DBG_DESC
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".MediaType: " &amp; objItem.MediaType, DBG_DESC
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".Size: " &amp; objItem.Size, DBG_DESC
Next
On Error Goto 0
End If

TotalLocalDiskUnit = ConvertToMatchingUnit(TotalLocalDisk)
DebugOut "TotalLocalDiskSize: " &amp; TotalLocalDiskUnit, DBG_INFO
DebugOut "TotalLocalDiskNo: " &amp; TotalLocalDiskNo, DBG_INFO


' get BMC IP addresses
'---------------------------------------
BMCIPv4Addr = "N/A"
BMCIPv6Addr = "N/A"
iRMCDNSName = "N/A"

If CIMProvider = True Then
SVAgentClass = "SVS_PGYComputerSystem"
Set colItems = WMIQuery(TargetComputer, SVNamespace, "SELECT * FROM " &amp; SVAgentClass, True)

If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem in colItems
If Not objItem.AdminUrlIPv4 = "" Then BMCIPv4Addr = objItem.AdminUrlIPv4 End If
If Not objItem.AdminUrlIPv6 = "" Then BMCIPv6Addr = objItem.AdminUrlIPv6 End If
If Not objItem.AdminUrlDNS = "" Then iRMCDNSName = objItem.AdminUrlDNS End If
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".AdminUrlIPv4: " &amp; objItem.AdminUrlIPv4, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".AdminUrlIPv6: " &amp; objItem.AdminUrlIPv6, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".AdminUrlDNS: " &amp; objItem.AdminUrlDNS, DBG_DESC
Exit For '***** only one instance possible
Next
On Error Goto 0
End If
Else
If SVAgentRunning = true Then
' check for iRMC
iRMCName = GetScciData(&amp;HC00, &amp;H508, &amp;H0, Cabinet)
If InStr(LCase(iRMCName), "irmc") &gt; 0 Then
BMCIPv4Addr = GetScciData(&amp;HE205, &amp;H0, &amp;H0, Cabinet)
BMCIPv6Addr = GetScciData(&amp;HE205, &amp;H1, &amp;H0, Cabinet)
If IsNull(BMCIPv4Addr) Or IsEmpty(BMCIPv4Addr) Or BMCIPv4Addr = "" Or Len(BMCIPv4Addr) = 0 Then BMCIPv4Addr = "N/A" End If
If IsNull(BMCIPv6Addr) Or IsEmpty(BMCIPv6Addr) Or BMCIPv6Addr = "" Or Len(BMCIPv6Addr) = 0 Then BMCIPv6Addr = "N/A" End If
If Not BMCIPv4Addr = "N/A" Then iRMCDNSName = GetiRMCDNSName End If
Else
End If
End If
End If
If iRMCDNSName = "N/A" Then iRMCDNSName = BMCIPv4Addr End If
DebugOut "BMC Address IPv4: " &amp; BMCIPv4Addr, DBG_INFO
DebugOut "BMC Address IPv6: " &amp; BMCIPv6Addr, DBG_INFO
DebugOut "BMC DNS name: " &amp; iRMCDNSName, DBG_INFO


' get the System Firmware informations
'-------------------------------------------
SystemFirmware = "N/A"

SVAgentClass = "Win32_BIOS"
Set colItems = WMIQuery(TargetComputer, cimv2NS, "SELECT * FROM " &amp; SVAgentClass, True)

If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem in colItems
SystemFirmware = Trim(objItem.SMBIOSBIOSVersion)
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".SMBIOSBIOSVersion: " &amp; objItem.SMBIOSBIOSVersion, DBG_DESC
Exit For
Next
On Error Goto 0
End If
DebugOut "SystemFirmware: " &amp; SystemFirmware, DBG_INFO

'ServerView RAID
'-------------------------------------------
SVRaidVersion = GetSVRaidVersion()
RaidManager = "N/A"
'If Len(SVRaidVersion) &gt; 0 And SVRaidVersion &gt;= SVRAIDVERSION_BASE Then
If Len(SVRaidVersion) &gt; 0 Then
RaidManager = SVRaidName &amp; " V" &amp; SVRaidVersion
End If

'--------------------------------------------
If insideMP = true Then
If Len(SVAgentName) &gt; 0 And Len(WMIVersion) &gt; 0 Then
DebugOut "Create Server instance: " &amp; ChassisModel, DBG_SCOM
Set oServer = oDiscoveryData.CreateClassInstance(serverClass)
AddObjectData oServer, FTSServerName, PrincipalName
AddMPElement oServer, "$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", TargetComputer
AddMPElement oServer, "$MPElement[Name='FTSLIB!Fujitsu.ServerView.System']/Model$", ModelName
AddMPElement oServer, "$MPElement[Name='FTSLIB!Fujitsu.ServerView.System']/SerialNumber$", SerialNumber
AddMPElement oServer, "$MPElement[Name='FTSLIB!Fujitsu.ServerView.System']/OperatingSystem$", OSName
AddMPElement oServer, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Server']/IPAddress$", IPAddress
AddMPElement oServer, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Server']/ChassisModel$", ChassisModel
AddMPElement oServer, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Server']/Cabinets$", Cabinets
AddMPElement oServer, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Server']/Manufacturer$", Manufacturer
AddMPElement oServer, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Server']/PhysicalMemory$", totalMemoryUnit
AddMPElement oServer, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Server']/TotalDisk$ ", TotalLocalDiskUnit
AddMPElement oServer, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Server']/BMC$", BMCIPv4Addr
AddMPElement oServer, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Server']/BMC_DNS$", iRMCDNSName
AddMPElement oServer, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Server']/SystemFirmware$", SystemFirmware
AddMPElement oServer, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Server']/MonitoringAgents$", MonitoringAgents
AddMPElement oServer, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Server']/RaidManager$", RaidManager
Call oDiscoveryData.AddInstance(oServer)

'***** Create instance of Health Collections
DebugOut "Create Health Collections instance: " &amp; "Fujitsu.HealthCollections", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.CollectionsHost']$")
AddObjectData oInst, "Fujitsu.HealthCollections", PrincipalName
Call oDiscoveryData.AddInstance(oInst)

'***** Create instance of Create instance of Software Components
DebugOut "Create Software Components instance: " &amp; "Software Components", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.SoftwareComponents']$")
AddObjectData oInst, "Software Components", PrincipalName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/ServerName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/BMCAddrIPv4$", BMCIPv4Addr
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/BMCAddr$", iRMCDNSName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.SimpleCollection']/NetworkName$", TargetComputer
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create relationship ServerContainsSoftware", DBG_SCOM
Set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerContainsSoftware']$")
oRelationship.Source = oServer
oRelationship.Target = oInst
Call oDiscoveryData.AddInstance(oRelationship)

'***** Create instance of SCCI (ServerView) component
DebugOut "Create SCCIManagement instance: " &amp; SVAgentName, DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.SCCIManagement']$")
AddSoftwareData oInst, SVAgentName, "Service 'SrvCtrl.exe'", SVAgentVersion, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create " &amp; SVAgentVersionString &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerViewAgentsVersion']$")
AddSoftwareVersionData oInst, SVAgentVersionString, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerViewAgentsVersion']/Version$", SVAgentVersion
Call oDiscoveryData.AddInstance(oInst)

'***** Create instance of WMI (Windows Management Instrumentation) component
DebugOut "Create WMIManagement instance: Windows Management Instrumentation", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.WMIManagement']$")
AddSoftwareData oInst, "Windows Management Instrumentation", "None", WMIVersion, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName
Call oDiscoveryData.AddInstance(oInst)

'If Len(SVRaidVersion) &gt; 0 And SVRaidVersion &gt;= SVRAIDVERSION_BASE Then
If Len(SVRaidVersion) &gt; 0 Then
DebugOut "Create RAIDManagement instance: " &amp; SVRaidName, DBG_SCOM
'***** Create instance of ServerView RAID component
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidManagement']$")
AddSoftwareData oInst, SVRaidName, "Service 'amService.exe'", SVRaidVersion, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create " &amp; SVRaidVersionString &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerViewRaidVersion']$")
AddSoftwareVersionData oInst, SVRaidVersionString, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerViewRaidVersion']/Version$", SVRaidVersion
Call oDiscoveryData.AddInstance(oInst)
End If
Else
Call oAPI.Return(oDiscoveryEmptyData)
If DebugMode = True Then WScript.Echo "" End If
DebugOut "***** Return oDiscoveryEmptyData to OM; Normal exit *****", DBG_ALL
WScript.Quit(1)
End If
End If

' check saved PRIMERGY Server Data
'--------------------------------------------------------------
SCOMAgentVersion = GetPYServerData("AgentVersion")
' No SVAgent Version means, all component data have been deleted or this is a new server
index = 0
if SCOMAgentVersion = "" Then
For Each objItem In ComponentsStateList
ComponentsPYServerData(index) = -1
ComponentsPYServerDataValid(index) = ""
index = index + 1
Next
Else
For Each objItem In ComponentsStateList
i = GetPYServerData(objItem)
If i &lt;&gt; "" Then
ComponentsPYServerData(index) = CStr(i)
Else
ComponentsPYServerData(index) = 0
End If
ComponentsPYServerDataValid(index) = GetPYServerData(objItem &amp; "Valid")
index = index + 1
Next
End If

' save SVAgent Version if necessary
if SCOMAgentVersion = "" Or SCOMAgentVersion &lt;&gt; SVAgentVersion Then
Call SavePYServerData("AgentVersion", SVAgentVersion)
End If


' Management Controller
'---------------------------------------------------------------
componentSubSystemType = MGMTCTRL
DebugOut "***** " &amp; ComponentsList(componentSubSystemType) &amp; " *****", DBG_ALL

InitStatus()
index = 0
Dim iRMCFirmware

If CIMProvider = True Then
SVAgentClass = "SVS_PGYManagementController"
Set colItems = WMIQuery(TargetComputer, SVNamespace, "SELECT * FROM " &amp; SVAgentClass, True)

If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem in colItems
iRMCName = objItem.ElementName
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".ElementName: " &amp; objItem.ElementName, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".HealthState: " &amp; objItem.HealthState, DBG_DESC
DebugOut ComponentsList(componentSubSystemType) &amp; ": '" &amp; iRMCName &amp; "', [" &amp; SCOM_HealthState(objItem.HealthState) &amp; "]", DBG_INFO

' Some of our servers do have some sort of BMC, but it is no proper iRMC. Skip these.
If (IsEmpty(objItem.ElementName) Or IsNull(objItem.ElementName)) And objItem.HealthState = 0 Then
DebugOut "Found some minor BMC which cannot be monitored. Skip.", DBG_INFO
Else
componentNameArray(index) = objItem.ElementName
componentStatusArray(index) = SCOM_HealthState(objItem.HealthState)
' BMC really does not have a health state. Assume OK if not OK (as with PQ).
If componentStatusArray(index) = STATUS_UNKNOWN Then componentStatusArray(index) = STATUS_OK End If
End If

If index &gt;= cMAXINDEX Then
Exit For
End If
index = index + 1
Next
On Error Goto 0
End If

index = 0
SVAgentClass = "SVS_PGYSoftwareIdentity"
Set colItems = WMIQuery(TargetComputer, SVNamespace, "SELECT * FROM " &amp; SVAgentClass &amp; " WHERE ElementName = '" &amp; iRMCName &amp; "'", True)

If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
'*** VBS runs into the loop, even if "WMISet = Nothing"
On Error Resume Next
For Each objItem in colItems
If Not (InStr(LCase(objItem.ElementName), "irmc") = 0) Then
DebugOut "Firmware Version: " &amp; objItem.VersionString, DBG_INFO
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".ElementName: " &amp; objItem.ElementName, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".VersionString: " &amp; objItem.VersionString, DBG_DESC
iRMCFirmware = objItem.VersionString
componentInfoArray(index) = "Firmware Version: " &amp; iRMCFirmware
index = 1
Exit For
End If
Next
On Error Goto 0
End If
Else
If iRMCName &lt;&gt; "" Then
' BMC does not have its own health state. Assume OK.
iRMCName = GetScciData(&amp;HC00, &amp;H508, &amp;H0, Cabinet)
iRMCFirmware = GetScciData(&amp;HC00, &amp;H506, &amp;H0, Cabinet)
DebugOut ComponentsList(componentSubSystemType) &amp; ": '" &amp; iRMCName &amp; "', [" &amp; STATUS_OK &amp; "]", DBG_INFO
DebugOut "Firmware Version: " &amp; iRMCFirmware, DBG_INFO

componentNameArray(index) = iRMCName
componentStatusArray(index) = STATUS_OK
componentInfoArray(index) = "Firmware Version: " &amp; iRMCFirmware
index = 1
End If
End If

componentNames = componentNameArray(0)
componentInfos = componentInfoArray(0)
DebugOut "Discovered Components: " &amp; componentNames, DBG_INFO
DebugOut "Discovered Component Infos: " &amp; componentInfos, DBG_INFO

If index &gt; 0 Then
If insideMP = true Then
DebugOut "Create " &amp; ComponentsList(componentSubSystemType) &amp; " instance: " &amp; componentNameArray(0), DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ManagementController']$")
AddComponentData oInst, componentSubSystemType, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ManagementController']/FirmwareVersion$", iRMCFirmware
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create relationship ServerContainsManagementController", DBG_SCOM
Set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerContainsManagementController']$")
oRelationship.Source = oServer
oRelationship.Target = oInst
Call oDiscoveryData.AddInstance(oRelationship)
End If

Call CheckSavedComponents(componentSubSystemType, index)
End If


'*** Processor
'-------------------------------------
componentSubSystemType = PROCESSOR
DebugOut "***** " &amp; ComponentsList(componentSubSystemType) &amp; " *****", DBG_ALL

InitStatus()
index = 0

SCCIIndex = GetComponents(CIMProvider, TargetComputer, componentSubSystemType)
DebugOut "Number of Processors: " &amp; SCCIIndex, DBG_INFO

If CIMProvider = True Then
If SCCIIndex &gt; 0 Then
index = 0
SVAgentClass = "SVS_PGYProcessor"
Set colItems = WMIQuery(TargetComputer, svsNS, "SELECT * FROM " &amp; SVAgentClass, True)

If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem in colItems
componentNameArray(index) = objItem.ElementName
componentInfoArray(index) = objItem.Name
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".ElementName: " &amp; objItem.ElementName, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".Name: " &amp; objItem.Name, DBG_DESC
'DebugOut "Processor " &amp; index &amp; ": '" &amp; componentNameArray(index) &amp; "', Type: '" &amp; componentInfoArray(index) &amp; "'"
index = index + 1
Next
On Error Goto 0
End If

SVAgentClass = "SVS_PGYProcessorCapabilities"
index = 0
Set colItems = WMIQuery(TargetComputer, svsNS, "SELECT * FROM " &amp; SVAgentClass, True)

If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem in colItems
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".NumberOfProcessorEnabledCores: " &amp; objItem.NumberOfProcessorEnabledCores, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".NumberOfHardwareEnabledThreads: " &amp; objItem.NumberOfHardwareEnabledThreads, DBG_DESC
If objItem.NumberOfProcessorEnabledCores &gt; 0 Then
componentInfoArray(index) = componentInfoArray(index) &amp; " / Enabled Cores: " &amp; objItem.NumberOfProcessorEnabledCores
End If
If objItem.NumberOfHardwareEnabledThreads &gt; 0 Then
componentInfoArray(index) = componentInfoArray(index) &amp; ", Enabled Threads: " &amp; objItem.NumberOfHardwareEnabledThreads
End If
DebugOut "Processor " &amp; index &amp; ": '" &amp; componentNameArray(index) &amp; "', Type: '" &amp; componentInfoArray(index) &amp; "'", DBG_INFO
index = index + 1
Next
On Error Goto 0
End If
End If

index = SCCIIndex
Else
If SVAgentRunning = true Then
index = SCCIIndex
If SCCIIndex &gt; 0 Then
For i=0 To SCCIIndex-1
'componentNameArray(i) = "CPU " &amp; i
componentInfoArray(i) = GetScciData(&amp;H605, &amp;H0, i, Cabinet) ' CPU Model Name
If componentNameArray(i) &lt;&gt; "" Then
intComponentValue = GetScciData(&amp;H606, &amp;H0, i, Cabinet) ' No. of logical CPUs (Cores)
If intComponentValue &gt; 0 Then
componentInfoArray(i) = componentInfoArray(i) &amp; " / Logical Cores: " &amp; intComponentValue
End If
End If
DebugOut "Processor " &amp; i &amp; ": '" &amp; componentNameArray(i) &amp; "', Type: '" &amp; componentInfoArray(i) &amp; "'", DBG_INFO
Next
End If
End If
End If

componentNames = "Processors: " &amp; index
componentInfos = ""
If componentCountEmpty &gt; 0 Then componentInfos = "Not populated Processors: " &amp; componentCountEmpty End If
DebugOut "Discovered Components: " &amp; componentNames, DBG_INFO
DebugOut "Discovered Component Infos: " &amp; componentInfos, DBG_INFO

If index &gt; 0 Then
If insideMP = true Then
DebugOut "Create " &amp; ComponentsList(componentSubSystemType) &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Processors']$")
AddComponentData oInst, componentSubSystemType, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create relationship ServerContainsProcessors", DBG_SCOM
Set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerContainsProcessors']$")
oRelationship.Source = oServer
oRelationship.Target = oInst
Call oDiscoveryData.AddInstance(oRelationship)

For i=0 To index-1
DebugOut "Create " &amp; "Processor" &amp; " instance: " &amp; componentNameArray(i), DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Processor']$")
AddSimpleDeviceData oInst, componentNameArray(i), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Processor']/ProcInfo$", componentInfoArray(i)
Call oDiscoveryData.AddInstance(oInst)
Next
End If

Call CheckSavedComponents(componentSubSystemType, index)
Else
DebugOut "Did not find any components of type '" &amp; ComponentsList(componentSubSystemType) &amp; "'", DBG_INFO
End If


'*** Memory
'-------------------------------------------
componentSubSystemType = MEMORY
DebugOut "***** " &amp; ComponentsList(componentSubSystemType) &amp; " *****", DBG_ALL

InitStatus()
index = 0
totalMemory = 0

SCCIIndex = GetComponents(CIMProvider, TargetComputer, componentSubSystemType)
DebugOut "Number of Memory Modules: " &amp; SCCIIndex, DBG_INFO

If CIMProvider = True Then
SVAgentClass = "SVS_PGYPhysicalMemory"
If SCCIIndex &gt; 0 Then
Set colItems = WMIQuery(TargetComputer, svsNS, "SELECT * FROM " &amp; SVAgentClass, True)
If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
index = 0
j = 0
For i=0 To SCCIIndex-1
For Each objItem in colItems
If componentNameArray(j) = objItem.Caption Then
' skip any memory without capacity. something is wrong with it
If objItem.Capacity &gt; 0 Then
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".Caption: " &amp; objItem.Caption, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".Capacity: " &amp; objItem.Capacity, DBG_DESC
componentNameArray(index) = componentNameArray(j)
totalMemory = totalMemory + objItem.Capacity
devProperty1(index) = ConvertToMatchingUnit(objItem.Capacity)
devProperty2(index) = objItem.Manufacturer
devProperty3(index) = objItem.PartNumber
devProperty4(index) = objItem.SerialNumber
componentInfoArray(index) = devProperty1(index)
DebugOut "Memory " &amp; index &amp; ": '" &amp; componentNameArray(index) &amp; "', size: " &amp; objItem.Capacity &amp; " (" &amp; componentInfoArray(index) &amp; ")", DBG_INFO
index = index + 1
End If
j = j + 1
End If
Next
Next
On Error Goto 0
End If
End If
Else
If SVAgentRunning = true Then
If SCCIIndex &gt; 0 Then
SCCIIndex = GetScciData(&amp;H700, &amp;H0, &amp;H0, Cabinet)
index = 0
j = 0
For i=0 To SCCIIndex-1
strComponentValue = GetScciData(&amp;H702, &amp;H0, i, Cabinet)
If componentNameArray(j) = strComponentValue Then
intComponentValue = GetScciData(&amp;H70A, &amp;H0, i, Cabinet)
If intComponentValue &gt; 0 Then
intComponentValue = intComponentValue * 1024 * 1024 '*** Size in GB
componentInfoArray(index) = ConvertToMatchingUnit(intComponentValue) ' Size
devProperty1(index) = componentInfoArray(index)
devProperty2(index) = GetScciData(&amp;HC00, &amp;H030A, i, Cabinet) ' Manufacturer
devProperty3(index) = GetScciData(&amp;HC00, &amp;H0301, i, Cabinet) ' PartNumber
devProperty4(index) = GetScciData(&amp;HC00, &amp;H0300, i, Cabinet) ' SerialNumber
totalMemory = totalMemory + intComponentValue
DebugOut "Memory " &amp; index &amp; ": '" &amp; componentNameArray(index) &amp; "', size: " &amp; intComponentValue &amp; " (" &amp; componentInfoArray(index) &amp; ")", DBG_INFO
index = index + 1
End If
j = j + 1
End If
Next
End If
End If
End If

totalMemory = ConvertToMatchingUnit(totalMemory)
DebugOut "Physical Memory: " &amp; totalMemory, DBG_INFO

componentNames = "Memory Modules: " &amp; index
componentInfos = "Overall Memory: " &amp; totalMemory

For i=0 To 50
devType(i) = ""
devNo(i) = 0
Next

For j=0 To SCCIIndex - 1
For i=0 To 50
If devType(i) = "" Then
devType(i) = componentInfoArray(j)
devNo(i) = 1
Exit For
ElseIf componentInfoArray(j) = devType(i) Then
devNo(i) = devNo(i) + 1
Exit For
End If
Next
Next

componentInfos = componentInfos &amp; "; "
For i=0 To 50
If Not devType(i) = "" Then
componentInfos = componentInfos &amp; "'" &amp; devType(i) &amp; "': " &amp; devNo(i) &amp; ", "
End If
Next
componentInfos = Left(componentInfos, Len(componentInfos) - 2)

If componentCountEmpty &gt; 0 Then componentInfos = componentInfos &amp; "; Not populated Memory Modules: " &amp; componentCountEmpty End If

DebugOut "Discovered Components: " &amp; componentNames, DBG_INFO
DebugOut "Discovered Component Infos: " &amp; componentInfos, DBG_INFO

If index &gt; 0 Then
If insideMP = true Then
'DoDiscoveryData(componentSubSystemType, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName)
DebugOut "Create " &amp; ComponentsList(componentSubSystemType) &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Memory']$")
AddComponentData oInst, componentSubSystemType, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create relationship ServerContainsMemory", DBG_SCOM
Set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerContainsMemory']$")
oRelationship.Source = oServer
oRelationship.Target = oInst
Call oDiscoveryData.AddInstance(oRelationship)

For i=0 To index-1
DebugOut "Create " &amp; "MemoryModule" &amp; " instance: " &amp; componentNameArray(i), DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.MemoryModule']$")
AddSimpleDeviceData oInst, componentNameArray(i), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.MemoryModule']/Capacity$", componentInfoArray(i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.MemoryModule']/Manufacturer$", devProperty2(i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.MemoryModule']/PartNumber$", devProperty3(i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.MemoryModule']/SerialNumber$", devProperty4(i)
Call oDiscoveryData.AddInstance(oInst)
Next
End If

Call CheckSavedComponents(componentSubSystemType, index)
Else
DebugOut "Did not find any components of type '" &amp; ComponentsList(componentSubSystemType) &amp; "'", DBG_INFO
End If


'*** Storage
'-----------------------------
componentSubSystemType = STORAGE

DebugOut "***** " &amp; ComponentsList(componentSubSystemType) &amp; " *****", DBG_ALL

InitStatus()
totalDiskSpace = 0
index = 0

SVAgentClass = "Win32_DiskDrive"
Set colItems = WMIQuery(TargetComputer, cimv2NS, "SELECT * FROM " &amp; SVAgentClass, True)

If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem in colItems
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".MediaType: " &amp; objItem.MediaType, DBG_DESC
If InStr(objItem.MediaType, "Removable") Then
DebugOut "Skipping removable media '" &amp; objItem.Caption &amp; "'.", DBG_INFO
ElseIf InStr(objItem.MediaType, "External") Then
DebugOut "Skipping external media '" &amp; objItem.Caption &amp; "'.", DBG_INFO
Else
componentNameArray(index) = objItem.Caption
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".Caption: " &amp; objItem.Caption, DBG_DESC
If objItem.Size &gt; 0 Then
totalDiskSpace = totalDiskSpace + objItem.Size
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".Size: " &amp; objItem.Size, DBG_DESC
componentInfoArray(index) = ConvertToMatchingUnit(objItem.Size)
devProperty1(index) = componentInfoArray(index)
devProperty3(index) = objItem.Model
devProperty5(index) = objItem.InterfaceType
' these two are only available for OS &gt; W2K3
If CInt(Left(OSVersion, 1)) &gt; 5 Then
devProperty2(index) = objItem.FirmwareRevision
devProperty4(index) = objItem.SerialNumber
End If
End If
DebugOut "Storage " &amp; index &amp; ": '" &amp; componentNameArray(index) &amp; "', size: " &amp; objItem.Size &amp; " (" &amp; componentInfoArray(index) &amp; ")", DBG_INFO

If index &gt;= cMAXINDEX Then
DebugOut "Max. no. of storage instances reached/exceeded", DBG_INFO
Exit For
End If
index = index + 1
End If
Next
DebugOut "Number of Storage Devices: " &amp; index, DBG_INFO
On Error Goto 0
End If

totalDiskSpace = ConvertToMatchingUnit(totalDiskSpace)
DebugOut "Disk Space: " &amp; totalDiskSpace, DBG_INFO

componentNames = "Storage Disks: " &amp; index
componentInfos = "Overall Disk Space: " &amp; totalDiskSpace

For i=0 To 50
devType(i) = ""
devNo(i) = 0
Next

For j=0 To SCCIIndex - 1
For i=0 To 50
If devType(i) = "" Then
devType(i) = componentInfoArray(j)
devNo(i) = 1
Exit For
ElseIf componentInfoArray(j) = devType(i) Then
devNo(i) = devNo(i) + 1
Exit For
End If
Next
Next

componentInfos = componentInfos &amp; "; "
For i=0 To 50
If Not devType(i) = "" Then
componentInfos = componentInfos &amp; "'" &amp; devType(i) &amp; "': " &amp; devNo(i) &amp; ", "
End If
Next
componentInfos = Left(componentInfos, Len(componentInfos) - 2)

DebugOut "Discovered Components: " &amp; componentNames, DBG_INFO
DebugOut "Discovered Component Infos: " &amp; componentInfos, DBG_INFO

If index &gt; 0 Then
If insideMP = true Then
DebugOut "Create " &amp; ComponentsList(componentSubSystemType) &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerStorage']$")
AddComponentData oInst, componentSubSystemType, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create relationship ServerContainsServerStorage", DBG_SCOM
Set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerContainsServerStorage']$")
oRelationship.Source = oServer
oRelationship.Target = oInst
Call oDiscoveryData.AddInstance(oRelationship)

For i=0 To index-1
DebugOut "Create " &amp; "StorageDisk" &amp; " instance: " &amp; componentNameArray(i), DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.StorageDisk']$")
AddSimpleDeviceData oInst, componentNameArray(i), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.StorageDisk']/Size$", componentInfoArray(i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.StorageDisk']/FirmwareRevision$", devProperty2(i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.StorageDisk']/ModelName$", devProperty3(i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.StorageDisk']/SerialNumber$", devProperty4(i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.StorageDisk']/InterfaceType$", devProperty5(i)
Call oDiscoveryData.AddInstance(oInst)
Next
End If

Call CheckSavedComponents(componentSubSystemType, index)
Else
DebugOut "Did not find any components of type '" &amp; ComponentsList(componentSubSystemType) &amp; "'", DBG_INFO
End If


'*** Network Adapter (Ethernet)
'-------------------------------------------
componentSubSystemType = NETWORK
DebugOut "***** " &amp; ComponentsList(componentSubSystemType) &amp; " *****", DBG_ALL

InitStatus()
index = 0

SVAgentClass = "Win32_NetworkAdapter"
Set colItems = WMIQuery(TargetComputer, cimv2NS, "SELECT * FROM " &amp; SVAgentClass, True)

If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
i = 0
For Each objItem in colItems
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".ProductName: " &amp; objItem.ProductName, DBG_DESC
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".AdapterType: " &amp; objItem.AdapterType, DBG_DESC
'DebugOut "Network Device: " &amp; objItem.ProductName, DBG_INFO

' Skip JAPANESE STRING! 'AND InStr(objItem.AdapterType, "Ethernet 802.3") &gt; 0 _
If objItem.ProductName &lt;&gt; "" _
And InStr(objItem.ProductName, "Microsoft") = 0 _
And InStr(objItem.AdapterType, " 802.3") &gt; 0 Then
'AND objItem.NetConnectionStatus &lt;&gt; "0" AND objItem.NetConnectionStatus &lt;&gt; "" _
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".Name: " &amp; objItem.Name, DBG_DESC
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".NetConnectionStatus: " &amp; objItem.NetConnectionStatus, DBG_DESC
DebugOut cimv2NS &amp; ":" &amp; SVAgentClass &amp; ".MACAddress: " &amp; objItem.MACAddress, DBG_DESC

componentNameArray(index) = objItem.Name &amp; " (" &amp; index &amp; ")"

devProperty1(index) = objItem.NetConnectionID
devProperty2(index) = objItem.ServiceName

If Len(objItem.NetConnectionStatus) = 0 Then ' unknown connection state, communication is monitored elsewhere so assume OK
componentStatusArray(index) = STATUS_OK
Else
If objItem.NetConnectionStatus = 6 Then ' hardware malfunction
componentStatusArray(index) = STATUS_ERROR
ElseIf objItem.NetConnectionStatus = 2 Then ' Adapter is connected
componentStatusArray(index) = STATUS_OK
Else ' Adapter is NOT connected
componentStatusArray(index) = STATUS_OK
End If

Select Case objItem.NetConnectionStatus
case 0: componentStatusArray(index) = STATUS_OK ' Disconnected: 0
case 1: componentStatusArray(index) = STATUS_OK ' Connecting: 1
case 2: componentStatusArray(index) = STATUS_OK ' Connected: 2
case 3: componentStatusArray(index) = STATUS_OK ' Disconnecting: 3
case 4: componentStatusArray(index) = STATUS_OK ' Hardware Not Present: 4
case 5: componentStatusArray(index) = STATUS_OK ' Hardware Disabled: 5
i = i + 1
case 6: componentStatusArray(index) = STATUS_ERROR ' Hardware Malfunction: 6
case 7: componentStatusArray(index) = STATUS_OK ' Media Disconnected: 7
case 8: componentStatusArray(index) = STATUS_OK ' Authenticating: 8
case 9: componentStatusArray(index) = STATUS_OK ' Authentication Succeeded: 9
case 10: componentStatusArray(index) = STATUS_OK ' Authentication Failed: 10
case 11: componentStatusArray(index) = STATUS_DEGRADED ' Invalid Address: 11
case 12: componentStatusArray(index) = STATUS_OK ' Credentials Required: 12
End Select
End If

componentInfoArray(index) = "N/A"
componentInfoArray(index) = ""
If Len(objItem.MACAddress) &gt; 0 Then
componentInfoArray(index) = objItem.MACAddress
End If

DebugOut "Network " &amp; index &amp; ": '" &amp; componentNameArray(index) &amp; "' (" &amp; objItem.ServiceName &amp; "), [" &amp; componentStatusArray(index) &amp; "], " &amp; componentInfoArray(index), DBG_INFO

If index &gt;= cMAXINDEX Then
DebugOut "Max. no. of Network Adapter/Port instances reached/exceeded", DBG_INFO
Exit For
End If
index = index + 1
End If
Next
On Error Goto 0
End If
DebugOut "Number of Network Devices: " &amp; index, DBG_INFO
DebugOut "Number of Disabled Network Devices: " &amp; i, DBG_INFO

componentNames = "Network Devices: " &amp; index
If i &gt; 0 Then componentInfos = "Disabled Network Devices: " &amp; i End If
DebugOut "Discovered Components: " &amp; componentNames, DBG_INFO
DebugOut "Discovered Component Infos: " &amp; componentInfos, DBG_INFO

If index &gt; 0 Then
If insideMP = true Then
DebugOut "Create " &amp; ComponentsList(componentSubSystemType) &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerNetworks']$")
AddComponentData oInst, componentSubSystemType, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create relationship ServerContainsServerNetworks", DBG_SCOM
Set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerContainsServerNetworks']$")
oRelationship.Source = oServer
oRelationship.Target = oInst
Call oDiscoveryData.AddInstance(oRelationship)

For i=0 To index-1
DebugOut "Create " &amp; "NetworkDevice" &amp; " instance: " &amp; componentNameArray(i), DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.NetworkDevice']$")
AddSimpleDeviceData oInst, componentNameArray(i), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.NetworkDevice']/MacAddress$", componentInfoArray(i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.NetworkDevice']/NetConnectionID$", devProperty1(i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.NetworkDevice']/ServiceName$", devProperty2(i)
Call oDiscoveryData.AddInstance(oInst)
Next
End If

Call CheckSavedComponents(componentSubSystemType, index)
Else
DebugOut "Did not find any components of type '" &amp; ComponentsList(componentSubSystemType) &amp; "'", DBG_INFO
End If


'*** Fans
'---------------------------------------------
componentSubSystemType = FANS
DebugOut "***** " &amp; ComponentsList(componentSubSystemType) &amp; " *****", DBG_ALL

InitStatus()
index = 0

index = GetComponents(CIMProvider, TargetComputer, componentSubSystemType)
DebugOut "Number of Fans: " &amp; index, DBG_INFO

componentNames = "Fan Devices: " &amp; index
componentInfos = ""
If componentCountEmpty &gt; 0 Then componentInfos = "Not populated Fans: " &amp; componentCountEmpty End If
DebugOut "Discovered Components: " &amp; componentNames, DBG_INFO
DebugOut "Discovered Component Infos: " &amp; componentInfos, DBG_INFO

If index &gt; 0 Then
If insideMP = true Then
DebugOut "Create " &amp; ComponentsList(componentSubSystemType) &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Fans']$")
AddComponentData oInst, componentSubSystemType, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create relationship ServerContainsFans", DBG_SCOM
Set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerContainsFans']$")
oRelationship.Source = oServer
oRelationship.Target = oInst
Call oDiscoveryData.AddInstance(oRelationship)

For i=0 To index-1
DebugOut "Create " &amp; "Fan" &amp; " instance: " &amp; componentNameArray(i), DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Fan']$")
AddSimpleDeviceData oInst, componentNameArray(i), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
Call oDiscoveryData.AddInstance(oInst)
Next
End If

Call CheckSavedComponents(componentSubSystemType, index)
Else
DebugOut "Did not find any components of type '" &amp; ComponentsList(componentSubSystemType) &amp; "'", DBG_INFO
End If


'*** Temperatures
'---------------------------
componentSubSystemType = TEMPERATURE
DebugOut "***** " &amp; ComponentsList(componentSubSystemType) &amp; " *****", DBG_ALL

InitStatus()
index = 0
SCCIIndex = 0

index = GetComponents(CIMProvider, TargetComputer, componentSubSystemType)
DebugOut "Number of Temperature Sensors: " &amp; index, DBG_INFO

componentNames = "Temperature Sensors: " &amp; index
componentInfos = ""
If componentCountEmpty &gt; 0 Then componentInfos = "Not populated Temperature Sensors: " &amp; componentCountEmpty End If
DebugOut "Discovered Components: " &amp; componentNames, DBG_INFO
DebugOut "Discovered Component Infos: " &amp; componentInfos, DBG_INFO

If index &gt; 0 Then
If insideMP = true Then
DebugOut "Create " &amp; ComponentsList(componentSubSystemType) &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.TemperatureSensors']$")
AddComponentData oInst, componentSubSystemType, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create relationship ServerContainsTemperatureSensors", DBG_SCOM
Set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerContainsTemperatureSensors']$")
oRelationship.Source = oServer
oRelationship.Target = oInst
Call oDiscoveryData.AddInstance(oRelationship)

For i=0 To index-1
DebugOut "Create " &amp; "TemperatureSensor" &amp; " instance: " &amp; componentNameArray(i), DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.TemperatureSensor']$")
AddSimpleDeviceData oInst, componentNameArray(i), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
Call oDiscoveryData.AddInstance(oInst)
Next
End If

Call CheckSavedComponents(componentSubSystemType, index)
Else
DebugOut "Did not find any components of type '" &amp; ComponentsList(componentSubSystemType) &amp; "'", DBG_INFO
End If


'*** Voltages
'---------------------------
componentSubSystemType = VOLTAGES
DebugOut "***** " &amp; ComponentsList(componentSubSystemType) &amp; " *****", DBG_ALL

InitStatus()
index = 0

index = GetComponents(CIMProvider, TargetComputer, componentSubSystemType)
DebugOut "Number of Voltage Sensors: " &amp; index, DBG_INFO

componentNames = "Voltage Sensors: " &amp; index
componentInfos = ""
If componentCountEmpty &gt; 0 Then componentInfos = "Not populated Voltage Sensors: " &amp; componentCountEmpty End If
DebugOut "Discovered Components: " &amp; componentNames, DBG_INFO
DebugOut "Discovered Component Infos: " &amp; componentInfos, DBG_INFO

If index &gt; 0 Then
If insideMP = true Then
DebugOut "Create " &amp; ComponentsList(componentSubSystemType) &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.VoltageSensors']$")
AddComponentData oInst, componentSubSystemType, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create relationship ServerContainsVoltageSensors", DBG_SCOM
Set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerContainsVoltageSensors']$")
oRelationship.Source = oServer
oRelationship.Target = oInst
Call oDiscoveryData.AddInstance(oRelationship)

For i=0 To index-1
DebugOut "Create " &amp; "VoltageSensor" &amp; " instance: " &amp; componentNameArray(i), DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.VoltageSensor']$")
AddSimpleDeviceData oInst, componentNameArray(i), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
Call oDiscoveryData.AddInstance(oInst)
Next
End If

Call CheckSavedComponents(componentSubSystemType, index)
Else
DebugOut "Did not find any components of type '" &amp; ComponentsList(componentSubSystemType) &amp; "'", DBG_INFO
End If


'*** Power Supplies
'-----------------------------
componentSubSystemType = POWERSUPPLY
DebugOut "***** " &amp; ComponentsList(componentSubSystemType) &amp; " *****", DBG_ALL

InitStatus()
index = 0
SCCIIndex = 0

index = GetComponents(CIMProvider, TargetComputer, componentSubSystemType)
DebugOut "Number of Power Supplies: " &amp; index, DBG_INFO

If CIMProvider = True Then
SVAgentClass = "SVS_PGYPowerProductionSensor"
If index &gt; 0 Then
Set colItems = WMIQuery(TargetComputer, svsNS, "SELECT * FROM " &amp; SVAgentClass, True)
If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
j = 0
For i=0 To index-1
For Each objItem in colItems
If Not StrComp(componentNameArray(j), Replace(objItem.DeviceID, "-", "/") &amp; " " &amp; objItem.ElementName) Then
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".ElementName: " &amp; objItem.ElementName, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".HealthState: " &amp; objItem.HealthState, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".DeviceID: " &amp; objItem.DeviceID, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".NominalReading: " &amp; objItem.NominalReading, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".CurrentReading: " &amp; objItem.CurrentReading, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".UnitModifier: " &amp; objItem.UnitModifier, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".RateUnits: " &amp; objItem.RateUnits, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".BaseUnits: " &amp; objItem.BaseUnits, DBG_DESC
If objItem.NominalReading &gt; 0 Then
devProperty1(j) = objItem.NominalReading &amp; "W" ' Nominal Reading
devProperty2(j) = objItem.CurrentReading * (10 ^ objItem.UnitModifier) &amp; "W" ' Current Reading
Else
devProperty1(j) = "N/A"
devProperty2(j) = ""
End If
DebugOut "PSU " &amp; j &amp; ": '" &amp; componentNameArray(j) &amp; "', Nominal Power: " &amp; devProperty1(j) &amp; ", Current Power: " &amp; devProperty2(j), DBG_INFO
j = j + 1
End If
Next
Next
On Error Goto 0
End If
End If
Else
If SVAgentRunning = true Then
Dim cab, l
If index &gt; 0 Then
SCCIIndex = GetScciData(&amp;H500, &amp;H0, &amp;H0, Cabinet)
j = 0
cab = 0
l = 0
For i=0 To SCCIIndex-1
strComponentValue = oSwitch.VBRequest(&amp;H504, &amp;H0, l, CabinetArray(cab), 0, 0, 0, ret)
if ret &lt;&gt; 0 Then
DebugOut "oSwitch: No Data for opCode=0x" &amp; Hex(&amp;H504) &amp; " opCodeExt=0x" &amp; Hex(&amp;H0) &amp; " objIndex=" &amp; l &amp; " cabID=" &amp; CabinetArray(cab), DBG_DESC
cab = cab + 1
l = 0
Else
DebugOut "oSwitch: opCode=0x" &amp; Hex(&amp;H504) &amp; " opCodeExt=0x" &amp; Hex(&amp;H0) &amp; " objIndex=" &amp; l &amp; " cabID=" &amp; CabinetArray(cab) &amp; " -&gt; scciValue = '" &amp; strComponentValue &amp; "'", DBG_DESC
End If

If Not StrComp(componentNameArray(j), CabinetArray(cab) &amp; "/" &amp; l &amp; " " &amp; strComponentValue) Then
devProperty1(j) = GetScciData(&amp;H507, &amp;H0, l, CabinetArray(cab))
If devProperty1(j) &gt; 0 Then
devProperty1(j) = devProperty1(j) &amp; "W"
devProperty2(j) = GetScciData(&amp;H506, &amp;H0, l, CabinetArray(cab)) &amp; "W"
Else
devProperty1(j) = "N/A"
End If
DebugOut "PSU " &amp; j &amp; ": '" &amp; componentNameArray(j) &amp; "', Nominal Power: " &amp; devProperty1(j) &amp; ", Current Power: " &amp; devProperty2(j), DBG_INFO
j = j + 1
End If
l = l + 1
Next
End If
End If
End If

componentNames = "Power Supplies: " &amp; index
componentInfos = ""
If componentCountEmpty &gt; 0 Then componentInfos = "Not populated Power Supplies: " &amp; componentCountEmpty End If
DebugOut "Discovered Components: " &amp; componentNames, DBG_INFO
DebugOut "Discovered Component Infos: " &amp; componentInfos, DBG_INFO

If index &gt; 0 Then
If insideMP = true Then
DebugOut "Create " &amp; ComponentsList(componentSubSystemType) &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.PowerSupplies']$")
AddComponentData oInst, componentSubSystemType, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create relationship ServerContainsPowerSupplies", DBG_SCOM
Set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerContainsPowerSupplies']$")
oRelationship.Source = oServer
oRelationship.Target = oInst
Call oDiscoveryData.AddInstance(oRelationship)

For i=0 To index-1
DebugOut "Create " &amp; "PowerSupply" &amp; " instance: " &amp; componentNameArray(i), DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.PowerSupply']$")
AddSimpleDeviceData oInst, componentNameArray(i), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.PowerSupply']/Nominal$", devProperty1(i)
Call oDiscoveryData.AddInstance(oInst)
Next
End If

Call CheckSavedComponents(componentSubSystemType, index)
Else
DebugOut "Did not find any components of type '" &amp; ComponentsList(componentSubSystemType) &amp; "'", DBG_INFO
End If


'*** Power Consumption
'-----------------------------
componentSubSystemType = POWERCONSUMP
DebugOut "***** " &amp; ComponentsList(componentSubSystemType) &amp; " *****", DBG_ALL
Dim PCPowerControlModeSet, PCPowerControlModePerformed

InitStatus()
index = 0

If CIMProvider = True Then
SVAgentClass = "SVS_PGYPowerConsumptionSensor"
Set colItems = WMIQuery(TargetComputer, SVNamespace, "SELECT * FROM " &amp; SVAgentClass, True)

index = 0
If WMIInstanceValid = FALSE Then
DebugOut "'" &amp; SVAgentClass &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem in colItems
' Info: ServerView Agents SCCI only supply the 'Total Power' sensor (#E0) with sensible values.
' Ignore all others here
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".Name: " &amp; objItem.Name, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".DeviceID: " &amp; objItem.DeviceID, DBG_DESC
DebugOut SVNamespace &amp; ":" &amp; SVAgentClass &amp; ".ElementName: " &amp; objItem.ElementName, DBG_DESC
If Instr(LCase(objItem.DeviceID), "e0") Then
If InStr(objItem.ElementName, "Total Power") Then
If InStr(objItem.ElementName, "Out") Then
DebugOut "Do not use OutPut PowerConsumption Sensor " &amp; objItem.ElementName, DBG_INFO
Else
DebugOut "PowerConsumption Sensor " &amp; objItem.ElementName &amp; ", CurrentState '" &amp; objItem.CurrentState &amp; "', Status " &amp; objItem.HealthState &amp; " [" &amp; SCOM_HealthState(objItem.HealthState) &amp; "]", DBG_INFO
componentNameArray(index) = "Power Level"
componentInfoArray(index) = "Sensor: " &amp; objItem.ElementName
index = index + 1
End If
Else
DebugOut "Skip PowerConsumption Sensor " &amp; objItem.ElementName , DBG_INFO
End If
Else
DebugOut "Ignore PowerConsumption Sensor " &amp; objItem.ElementName , DBG_INFO
End If
Next
On Error Goto 0
End If
Else
If SVAgentRunning = true Then
Dim PCIndex, PCDesignation, PCCurrentVal, PCLimitStatus
Dim PCComponentClass, PCComponentArray
PCComponentClass = Array(&amp;H00, &amp;H1D, &amp;H20, &amp;H03, &amp;H0A, &amp;HE0)
PCComponentArray = Array("All", "Fan", "Memory", "CPU", "Power Supply", "Total")

' Info: ServerView Agents SCCI only supply the 'Total Power' sensor with sensible values.
' Ignore all others here for now and only request Total Power
On Error Resume Next
PCIndex = 5
' For PCIndex=1 To Ubound(PCComponentClass)
SCCIindex = GetScciData(&amp;H0531, PCComponentClass(PCIndex), &amp;H0, Cabinet)
If IsNull(SCCIIndex) Or Len(SCCIIndex) = 0 Then SCCIIndex = 0 End If
DebugOut "PowerConsumptionClassComponents '" &amp; PCComponentArray(PCIndex) &amp; "' Number: " &amp; SCCIindex , DBG_DESC
For i=0 To SCCIindex-1
PCDesignation = GetScciData(&amp;H0532, PCComponentClass(PCIndex), i, Cabinet)
If PCComponentClass(PCIndex) = &amp;HE0 Then
If InStr(PCDesignation, "Out") Then
DebugOut "Do not use OutPut PowerConsumption Sensor " &amp; PCDesignation, DBG_INFO
Else
DebugOut "PowerConsumption Sensor '" &amp; PCIndex &amp; "/" &amp; i &amp; "' (0x" &amp; Hex(PCComponentClass(PCIndex)) &amp; ") '" &amp; PCDesignation &amp; "'", DBG_INFO
componentNameArray(index) = "Power Level"
componentInfoArray(index) = "Sensor: " &amp; PCDesignation
index = index + 1
End If
Else
DebugOut "Ignore PowerConsumption Sensor " &amp; PCDesignation, DBG_INFO
End If
Next
' Next
On Error Goto 0
End If
End If
DebugOut "Number of Power Consumption Sensors: " &amp; index, DBG_INFO

componentNames = componentNameArray(0)
componentInfos = componentInfoArray(0)
DebugOut "Discovered Components: " &amp; componentNames, DBG_INFO
DebugOut "Discovered Component Infos: " &amp; componentInfos, DBG_INFO

If index &gt; 0 Then
If insideMP = true Then
DebugOut "Create " &amp; ComponentsList(componentSubSystemType) &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.PowerConsumption']$")
AddComponentData oInst, componentSubSystemType, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create relationship ServerContainsPowerConsumption", DBG_SCOM
Set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerContainsPowerConsumption']$")
oRelationship.Source = oServer
oRelationship.Target = oInst
Call oDiscoveryData.AddInstance(oRelationship)
End If

Call CheckSavedComponents(componentSubSystemType, index)
Else
DebugOut "Did not find any components of type '" &amp; ComponentsList(componentSubSystemType) &amp; "'", DBG_INFO
End If


'*** RAID Subsystem
'-----------------------------
componentSubSystemType = RAIDSUBSYSTEM
DebugOut "***** " &amp; ComponentsList(RAIDSUBSYSTEM) &amp; " *****", DBG_ALL
DebugOut "***** " &amp; ComponentsList(LOGICALDRIVE) &amp; " *****", DBG_ALL
DebugOut "***** " &amp; ComponentsList(PHYSICALDISK) &amp; " *****", DBG_ALL

InitStatus()
index = 0

Const MaxAdapter = 5
Const MaxLD = 100
Const MaxPD = 256

Dim ctrlIndex, ldIndex, pdIndex
ReDim ldIndex(MaxAdapter)
ReDim pdIndex(MaxAdapter)
Dim adapterNameArray, adapterInfoArray
ReDim adapterNameArray(MaxAdapter)
ReDim adapterInfoArray(MaxAdapter)

Dim LDperCtrlNameArray, LDperCtrlInfoArray
ReDim LDperCtrlNameArray(MaxAdapter, MaxLD)
ReDim LDperCtrlInfoArray(MaxAdapter, MaxLD)
Dim PDperCtrlNameArray, PDperCtrlInfoArray
ReDim PDperCtrlNameArray(MaxAdapter, MaxPD)
ReDim PDperCtrlInfoArray(MaxAdapter, MaxPD)

Dim LDProperty1, LDProperty2
ReDim LDProperty1(MaxAdapter, MaxLD)
ReDim LDProperty2(MaxAdapter, MaxLD)

Dim PDProperty1, PDProperty2, PDProperty3, PDProperty4
ReDim PDProperty1(MaxAdapter, MaxPD)
ReDim PDProperty2(MaxAdapter, MaxPD)
ReDim PDProperty3(MaxAdapter, MaxPD)
ReDim PDProperty4(MaxAdapter, MaxPD)

Dim ldIndexAll, pdIndexAll
Dim ldInfos, pdInfos
Dim pos

If SVAgentRunning = true Then
ctrlIndex = 0
ldIndexAll = 0
pdIndexAll = 0
ctrlIndex = GetScciData(&amp;H2110, 0, 0, Cabinet)
DebugOut "Number of RAID controllers: " &amp; ctrlIndex, DBG_INFO

If Len(ctrlIndex) &gt; 0 And ctrlIndex &gt; 0 Then
For pos=0 To ctrlIndex - 1
strComponentValue = GetScciData(&amp;H2111, &amp;H0, pos, Cabinet)
If Len(strComponentValue) &gt; 0 Then
adapterNameArray(pos) = strComponentValue
Else
adapterNameArray(pos) = "Adapter " &amp; pos
End If

intComponentValue = GetScciData(&amp;H2112, &amp;H0, pos, Cabinet)
Select Case intComponentValue
case 0: adapterInfoArray(pos) = "SCSI"
case 1: adapterInfoArray(pos) = "ATAPI"
case 2: adapterInfoArray(pos) = "PATA"
case 3: adapterInfoArray(pos) = "Firewire IEEE 1394"
case 4: adapterInfoArray(pos) = "SSA"
case 5: adapterInfoArray(pos) = "Fibre"
case 6: adapterInfoArray(pos) = "USB"
case 7: adapterInfoArray(pos) = "SATA"
case 8: adapterInfoArray(pos) = "SAS"
case 9: adapterInfoArray(pos) = "RAID"
case 10: adapterInfoArray(pos) = "MMC"
case 11: adapterInfoArray(pos) = "SD card bus"
End Select
DebugOut "RAID Controller " &amp; pos &amp; ", Name " &amp; adapterNameArray(pos) &amp; ", " &amp; adapterInfoArray(pos), DBG_INFO

devProperty1(pos) = GetScciProperty(&amp;H211D, &amp;H0, pos, Cabinet, "Vendor")
devProperty2(pos) = GetScciProperty(&amp;H211D, &amp;H0, pos, Cabinet, "SerialNumber")
strComponentValue = GetScciProperty(&amp;H211D, &amp;H0, pos, Cabinet, "DriverName")
If Len(strComponentValue) &gt; 0 Then
devProperty3(pos) = strComponentValue &amp; ", V" &amp; GetScciProperty(&amp;H211D, &amp;H0, pos, Cabinet, "DriverVersion")
Else
devProperty3(pos) = ""
End If
devProperty4(pos) = GetScciProperty(&amp;H211D, &amp;H0, pos, Cabinet, "FirmwareVersion")

ldIndex(pos) = 0
ldIndex(pos) = GetScciData(&amp;H2150, pos, 0, Cabinet)
If Len(ldIndex(pos)) &gt; 0 And ldIndex(pos) &gt; 0 Then
DebugOut "Number of Log. Drives on RAID Adapter " &amp; adapterNameArray(pos) &amp; ": " &amp; ldIndex(pos), DBG_INFO

On Error Resume next
For i=0 To ldIndex(pos)-1
strComponentValue = GetScciData(&amp;H2152, pos, i, Cabinet)
intComponentValue = GetScciData(&amp;H2155, pos, i, Cabinet)

If Len(strComponentValue) &gt; 0 Then
j = InStr(strComponentValue, " (")
If j &gt; 0 Then
strComponentValue = Left(strComponentValue, j-1)
End If
LDperCtrlNameArray(pos, i) = strComponentValue &amp; " (" &amp; pos &amp; "/" &amp; i &amp; ")"
Else
LDperCtrlNameArray(pos, i) = "Logical Drive (" &amp; pos &amp; "/" &amp; i &amp; ")"
End If

If Len(intComponentValue) &gt; 0 Then
LDperCtrlInfoArray(pos, i) = intComponentValue
'Else
'LDperCtrlInfoArray(pos, i) = "None"
End If
LDProperty1(pos, i) = GetScciData(&amp;H2153, pos, i, Cabinet)
If VarType(LDProperty1(pos, i)) = 2 Or VarType(LDProperty1(pos, i)) = 3 Then
cabString = CabinetLongToString(LDProperty1(pos, i))
Else
cabString = CabinetByteArrayToString(LDProperty1(pos, i))
End If
LDProperty1(pos, i) = ConvertToMatchingUnit(CLng("&amp;H" &amp; cabString) * 1024 * 1024)
DebugOut "LDProperty1(" &amp; pos &amp; "," &amp; i &amp; "): '" &amp; LDProperty1(pos, i) &amp; "'", DBG_INFO

LDProperty2(pos, i) = GetScciData(&amp;H2154, pos, i, Cabinet)
If VarType(LDProperty2(pos, i)) = 2 Or VarType(LDProperty2(pos, i)) = 3 Then
cabString = CabinetLongToString(LDProperty2(pos, i))
Else
cabString = CabinetByteArrayToString(LDProperty2(pos, i))
End If
LDProperty2(pos, i) = ConvertToMatchingUnit(CLng("&amp;H" &amp; cabString) * 1024 * 1024)
DebugOut "LDProperty2(" &amp; pos &amp; "," &amp; i &amp; "): '" &amp; LDProperty2(pos, i) &amp; "'", DBG_INFO

DebugOut "Log. Drive " &amp; pos &amp; "/" &amp; i &amp; ": " &amp; LDperCtrlNameArray(pos, i) &amp; " " &amp; LDperCtrlInfoArray(pos, i), DBG_INFO
ldIndexAll = ldIndexAll + 1
Next
On Error Goto 0
Else
ldIndex(pos) = 0
End If

pdIndex(pos) = 0
pdIndex(pos) = GetScciData(&amp;H2130, pos, 0, Cabinet)
If Len(pdIndex(pos)) &gt; 0 And pdIndex(pos) &gt; 0 Then
DebugOut "Number of Phys. Disks on RAID Adapter " &amp; adapterNameArray(pos) &amp; ": " &amp; pdIndex(pos), DBG_INFO

For i=0 To pdIndex(pos)-1
strComponentValue = GetScciData(&amp;H2133, pos, i, Cabinet)
intComponentValue = GetScciData(&amp;H2135, pos, i, Cabinet) * 1024 * 1024

If Len(strComponentValue) &gt; 0 Then
j = InStr(strComponentValue, " (")
If j &gt; 0 Then
strComponentValue = Left(strComponentValue, j-1)
End If
PDperCtrlNameArray(pos, i) = strComponentValue &amp; " (" &amp; pos &amp; "/" &amp; i &amp; ")"
Else
PDperCtrlNameArray(pos, i) = "Physical Disk (" &amp; pos &amp; "/" &amp; i &amp; ")"
End If

If Len(intComponentValue) &gt; 0 Then
PDperCtrlInfoArray(pos, i) = ConvertToMatchingUnit(intComponentValue)
'Else
'PDperCtrlInfoArray(pos, i) = "None"
End If
PDProperty1(pos, i) = GetScciProperty(&amp;H213D, &amp;H0, pos, Cabinet, "FirmwareVersion")
PDProperty2(pos, i) = GetScciProperty(&amp;H213D, &amp;H0, pos, Cabinet, "Product")
PDProperty3(pos, i) = GetScciProperty(&amp;H213D, &amp;H0, pos, Cabinet, "SerialNumber")
PDProperty4(pos, i) = GetScciProperty(&amp;H213D, &amp;H0, pos, Cabinet, "Vendor")

DebugOut "Phys. Disk " &amp; pos &amp; "/" &amp; i &amp; ": " &amp; PDperCtrlNameArray(pos, i) &amp; " " &amp; PDperCtrlInfoArray(pos, i), DBG_INFO
pdIndexAll = pdIndexAll + 1
Next
Else
pdIndex(pos) = 0
End If
Next
Else
ctrlIndex = 0
End If
End If
DebugOut "Number of RAID Controllers: " &amp; ctrlIndex, DBG_INFO
DebugOut "Number of Log. Drives: " &amp; ldIndexAll, DBG_INFO
DebugOut "Number of Phys. Disks: " &amp; pdIndexAll, DBG_INFO

For i=0 To 50
devType(i) = ""
devNo(i) = 0
Next

For pos=0 To ctrlIndex - 1
For i=0 To ldIndex(pos)-1
For index=0 To 50
If devType(index) = "" Then
devType(index) = LDperCtrlInfoArray(pos, i)
devNo(index) = 1
Exit For
ElseIf LDperCtrlInfoArray(pos, i) = devType(index) Then
devNo(index) = devNo(index) + 1
Exit For
End If
Next
Next
Next

ldInfos = ""
For i=0 To 50
If Not devType(i) = "" Then
ldInfos = ldInfos &amp; "'" &amp; devType(i) &amp; "': " &amp; devNo(i) &amp; ", "
End If
Next
If Len(ldInfos) &gt; 2 Then
ldInfos = Left(ldInfos, Len(ldInfos) - 2)
End If

For i=0 To 50
devType(i) = ""
devNo(i) = 0
Next

For pos=0 To ctrlIndex - 1
For i=0 To pdIndex(pos)-1
For index=0 To 50
If devType(index) = "" Then
devType(index) = PDperCtrlInfoArray(pos, i)
devNo(index) = 1
Exit For
ElseIf PDperCtrlInfoArray(pos, i) = devType(index) Then
devNo(index) = devNo(index) + 1
Exit For
End If
Next
Next
Next

pdInfos = ""
For i=0 To 50
If Not devType(i) = "" Then
pdInfos = pdInfos &amp; "'" &amp; devType(i) &amp; "': " &amp; devNo(i) &amp; ", "
End If
Next
If Len(pdInfos) &gt; 2 Then
pdInfos = Left(pdInfos, Len(pdInfos) - 2)
End If

componentNames = "RAID Controllers: " &amp; ctrlIndex
componentInfos = "Logical Drives: " &amp; ldIndexAll
If ldInfos &lt;&gt; "" Then componentInfos = componentInfos &amp; ", " &amp; ldInfos End If
componentInfos = componentInfos &amp; "; Physical Disks: " &amp; pdIndexAll
If pdInfos &lt;&gt; "" Then componentInfos = componentInfos &amp; ", " &amp; pdInfos End If

DebugOut "Discovered Components: " &amp; componentNames, DBG_INFO
DebugOut "Discovered Component Infos: " &amp; componentInfos, DBG_INFO

If ctrlIndex &gt; 0 Then
If insideMP = true Then
DebugOut "Create " &amp; "RaidComponents" &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidComponents']$")
AddComponentData oInst, RAIDSUBSYSTEM, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create relationship ServerContainsRaid", DBG_SCOM
Set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerContainsRaid']$")
oRelationship.Source = oServer
oRelationship.Target = oInst
Call oDiscoveryData.AddInstance(oRelationship)

DebugOut "Create " &amp; SVRaidOverallState &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.SVRaidOverallState']$")
AddOtherDeviceData oInst, SVRaidOverallState, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName
Call oDiscoveryData.AddInstance(oInst)

' *** loop though controllers
For pos=0 To ctrlIndex-1
DebugOut "Create " &amp; "RAID Controller " &amp; pos &amp; " instance: " &amp; adapterNameArray(pos), DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidController']$")
AddRaidControllerData oInst, "RAID Controller " &amp; pos, adapterNameArray(pos), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidController']/Type$", adapterInfoArray(pos)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidController']/Vendor$", devProperty1(pos)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidController']/SerialNumber$", devProperty2(pos)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidController']/Driver$", devProperty3(pos)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidController']/FirmwareVersion$", devProperty4(pos)
Call oDiscoveryData.AddInstance(oInst)

If ldIndex(pos) &gt; 0 Then
DebugOut "Create " &amp; ComponentsList(LOGICALDRIVE) &amp; " " &amp; pos &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidLogicalDrives']$")
AddRaidDeviceGroupData oInst, ComponentsList(LOGICALDRIVE) &amp; " " &amp; pos, adapterNameArray(pos), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName
Call oDiscoveryData.AddInstance(oInst)

For i=0 To ldIndex(pos)-1
DebugOut "Create " &amp; "RAID Logical Drive " &amp; pos &amp; "/" &amp; i &amp; " instance: " &amp; LDperCtrlNameArray(pos, i), DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidLogicalDrive']$")
AddRaidDeviceData oInst, "RAID Logical Drive " &amp; pos &amp; "/" &amp; i, adapterNameArray(pos), LDperCtrlNameArray(pos, i), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidLogicalDrive']/Type$", LDperCtrlInfoArray(pos, i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidLogicalDrive']/Size$", LDProperty1(pos, i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidLogicalDrive']/PhysicalSize$", LDProperty2(pos, i)
Call oDiscoveryData.AddInstance(oInst)
Next
Else
DebugOut "Did not find any components of type '" &amp; ComponentsList(LOGICALDRIVE) &amp; "' on " &amp; ComponentsList(RAIDSUBSYSTEM) &amp; " " &amp; pos &amp; " instance (" &amp; adapterNameArray(pos) &amp; ")", DBG_SCOM
End If

' *** handle physical disks per controller
If pdIndex(pos) &gt; 0 Then
DebugOut "Create " &amp; ComponentsList(PHYSICALDISK) &amp; " " &amp; pos &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidPhysicalDisks']$")
AddRaidDeviceGroupData oInst, ComponentsList(PHYSICALDISK) &amp; " " &amp; pos, adapterNameArray(pos), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName
Call oDiscoveryData.AddInstance(oInst)

For i=0 To pdIndex(pos)-1
DebugOut "Create " &amp; "RAID Physical Disk " &amp; pos &amp; "/" &amp; i &amp; " instance: " &amp; PDperCtrlNameArray(pos, i), DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidPhysicalDisk']$")
AddRaidDeviceData oInst, "RAID Physical Disk " &amp; pos &amp; "/" &amp; i, adapterNameArray(pos), PDperCtrlNameArray(pos, i), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidPhysicalDisk']/Size$", PDperCtrlInfoArray(pos, i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidPhysicalDisk']/FirmwareRevision$", PDProperty1(pos, i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidPhysicalDisk']/ModelName$", PDProperty2(pos, i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidPhysicalDisk']/SerialNumber$", PDProperty3(pos, i)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.RaidPhysicalDisk']/VendorName$", PDProperty4(pos, i)

Call oDiscoveryData.AddInstance(oInst)
Next
Else
DebugOut "Did not find any components of type '" &amp; ComponentsList(PHYSICALDISK) &amp; "' on " &amp; ComponentsList(RAIDSUBSYSTEM) &amp; " " &amp; pos &amp; " instance (" &amp; adapterNameArray(pos) &amp; ")", DBG_INFO
End If
Next
End If

Call CheckSavedComponents(RAIDSUBSYSTEM, ctrlIndex)
Call CheckSavedComponents(LOGICALDRIVE, ldIndexAll)
Call CheckSavedComponents(PHYSICALDISK, pdIndexAll)
Else
DebugOut "Did not find any components of type '" &amp; ComponentsList(RAIDSUBSYSTEM) &amp; "'", DBG_INFO
DebugOut "Did not find any components of type '" &amp; ComponentsList(LOGICALDRIVE) &amp; "'", DBG_INFO
DebugOut "Did not find any components of type '" &amp; ComponentsList(PHYSICALDISK) &amp; "'", DBG_INFO
End If


'*** Other
'-----------------------------
componentSubSystemType = OTHER
DebugOut "***** " &amp; ComponentsList(componentSubSystemType) &amp; " *****", DBG_ALL

InitStatus()

If Len(SVAgentVersion) &gt; 0 Then
If SVAgentRunning = false Then
componentNameArray(0) = SVAgentOverallState
componentInfoArray(0) = ""
componentNameArray(1) = SVCommunicationMonitor
componentInfoArray(1) = ""
index = 3
Else
index = GetComponents(CIMProvider, TargetComputer, componentSubSystemType)
End If
DebugOut "Number of Other components: " &amp; index, DBG_INFO

componentNames = "Other Components: " &amp; index
DebugOut "Discovered Components: " &amp; componentNames, DBG_INFO
DebugOut "Discovered Component Infos: " &amp; componentInfos, DBG_INFO

If insideMP = true Then
DebugOut "Create " &amp; ComponentsList(componentSubSystemType) &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.OtherComponents']$")
AddComponentData oInst, componentSubSystemType, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager
Call oDiscoveryData.AddInstance(oInst)

DebugOut "Create relationship ServerContainsOtherComponents", DBG_SCOM
Set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ServerContainsOtherComponents']$")
oRelationship.Source = oServer
oRelationship.Target = oInst
Call oDiscoveryData.AddInstance(oRelationship)

If index &gt; 0 Then
DebugOut "Create " &amp; componentNameArray(0) &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.SVOverallState']$")
AddOtherDeviceData oInst, componentNameArray(0), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName
Call oDiscoveryData.AddInstance(oInst)
End If
If index &gt; 1 Then
DebugOut "Create " &amp; componentNameArray(1) &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.CommunicationMonitor']$")
AddOtherDeviceData oInst, componentNameArray(1), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName
Call oDiscoveryData.AddInstance(oInst)
End If
If index &gt; 2 Then
DebugOut "Create " &amp; componentNameArray(2) &amp; " instance", DBG_SCOM
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.BiosSelftest']$")
AddOtherDeviceData oInst, componentNameArray(2), PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName
Call oDiscoveryData.AddInstance(oInst)
End If
End If

Call CheckSavedComponents(componentSubSystemType, index)
End If

'*** Send the data to OpsMgr
'------------------------------------------------
If insideMP = true Then
DebugOut "***** Return oDiscoveryData to OM; Normal exit *****", DBG_ALL
Call oAPI.Return(oDiscoveryData) ' Submit the data
If DebugMode = True Then WScript.Echo "" End If
End If

DebugOut "***** Normal end of script. *****", DBG_ALL

If DebugFile = True Then
If IsObject(oLogStream) Then oLogStream.Close() End If
End If

End Sub ' End Of "Main()"


'****************************************************************
'****************************************************************
'****************************************************************

Function GetWMIVersion(TargetComputer)
Dim WMIRunningVersion
Dim objWMI, colWMISettings, objWMISetting

Set objWMISetting = GetObject("winmgmts:{impersonationLevel=impersonate}\\.\root\default").Get("__CIMOMIdentification=@") 'only one instance

WMIRunningVersion = objWMISetting.VersionCurrentlyRunning
DebugOut "WMI Version: " &amp; WMIRunningVersion, DBG_INFO

GetWMIVersion = WMIRunningVersion
End Function

'****************************************************************

Sub InitStatus()
Dim i

for i = 0 to cMAXINDEX
componentStatusArray(i) = ""
componentNameArray(i) = ""
componentInfoArray(i) = ""
devProperty1(i) = ""
devProperty2(i) = ""
devProperty3(i) = ""
devProperty4(i) = ""
devProperty5(i) = ""
Next

componentNames = ""
componentStatus = ""
componentInfos = ""

End Sub

'****************************************************************

Function GetComponents(CIMProvider, TargetComputer, SubSystemNumber)
Dim componentHealthState, componentHealthStateNumber, SVAgentClass
Dim colItems, objItem, index, ret
Dim sysNo, subsysNo, subsyscompNo, subsyscompWord, scciState, scciName, scciDesc
Dim i, j, k, l
Dim SubSystem, scciText, cab
Dim DevCabinet, DevIndex

componentCount = 0
componentCountEmpty = 0

If CIMProvider = True Then
SVAgentClass = "SVS_PGYHealthStateComponent"
SubSystem = cimHealthStateSubsystem(SubSystemNumber)

If SubSystemNumber = OTHER Then
DebugOut "GetComponents for '" &amp; SubSystem &amp; "'", DBG_DATA
Set colItems = WMIQuery(TargetComputer, svsNS, "SELECT * FROM " &amp; SVAgentClass &amp; " WHERE Caption='" &amp; Subsystem &amp; "'", True)

If WMIInstanceValid = FALSE Then
DebugOut SVAgentClass &amp; " for '" &amp; SubSystem &amp; "' delivered no data.", DBG_DATA
Else
On Error Resume Next
For Each objItem in colItems
DebugOut svsNS &amp; ":" &amp; SVAgentClass &amp; ".ElementName: " &amp; objItem.ElementName, DBG_DESC
DebugOut svsNS &amp; ":" &amp; SVAgentClass &amp; ".HealthState: " &amp; objItem.HealthState, DBG_DESC
componentNameArray(componentCount) = SVAgentOverallState
DebugOut "Component " &amp; componentCount &amp; ": '" &amp; componentNameArray(componentCount) &amp; "', " &amp; objItem.HealthState &amp; " [" &amp; SCOM_HealthState(objItem.HealthState) &amp; "]", DBG_DATA
componentCount = componentCount + 1

componentNameArray(componentCount) = SVCommunicationMonitor
DebugOut "Component " &amp; componentCount &amp; ": " &amp; componentNameArray(componentCount) &amp; ": " &amp; objItem.HealthState &amp; " [" &amp; componentStatusArray(componentCount) &amp; "]", DBG_DATA
componentCount = componentCount + 1
Next
On Error Goto 0
End If
SubSystem = cimHealthStateSubsystem(SELFTEST)
End If

DebugOut "GetComponents for '" &amp; SubSystem &amp; "'", DBG_DATA
Set colItems = WMIQuery(TargetComputer, svsNS, "SELECT * FROM " &amp; SVAgentClass &amp; " WHERE Caption LIKE '%" &amp; SubSystem &amp; "%'", True)

If WMIInstanceValid = FALSE Then
DebugOut SVAgentClass &amp; " for '" &amp; SubSystem &amp; "' delivered no data.", DBG_DATA
Else
index = 0
DevCabinet = Cabinet
On Error Resume Next
For Each objItem in colItems
If SubSystemNumber = OTHER Then
DebugOut svsNS &amp; ":" &amp; SVAgentClass &amp; ".ElementName: " &amp; objItem.ElementName, DBG_DESC
DebugOut svsNS &amp; ":" &amp; SVAgentClass &amp; ".HealthState: " &amp; objItem.HealthState, DBG_DESC
componentNameArray(componentCount) = objItem.ElementName
DebugOut "Component " &amp; index &amp; ": '" &amp; componentNameArray(componentCount) &amp; "', " &amp; objItem.HealthState &amp; " [" &amp; SCOM_HealthState(objItem.HealthState) &amp; "]", DBG_DATA
componentCount = componentCount + 1 ' we only count existing components
End If
' It is an actual component if the InstanceID is something like '0-0-0-0'
' Except for PowerConsumption where we need to request the '0-0-0' Level
DebugOut svsNS &amp; ":" &amp; SVAgentClass &amp; ".Caption: " &amp; objItem.Caption, DBG_DESC
DebugOut svsNS &amp; ":" &amp; SVAgentClass &amp; ".InstanceID: " &amp; objItem.InstanceID, DBG_DESC
If UBound(Split(objItem.InstanceID, "-")) &gt; 2 Or (SubSystemNumber = POWERCONSUMP And UBound(Split(objItem.InstanceID, "-")) &gt; 1) Then
DebugOut svsNS &amp; ":" &amp; SVAgentClass &amp; ".Presence: " &amp; objItem.Presence, DBG_DESC
DebugOut svsNS &amp; ":" &amp; SVAgentClass &amp; ".ElementName: " &amp; objItem.ElementName, DBG_DESC
DebugOut svsNS &amp; ":" &amp; SVAgentClass &amp; ".HealthState: " &amp; objItem.HealthState, DBG_DESC
If SubSystemNumber = FANS Or SubSystemNumber = TEMPERATURE Or SubSystemNumber = POWERSUPPLY Then
DebugOut svsNS &amp; ":" &amp; SVAgentClass &amp; ".AssociationKey: " &amp; objItem.AssociationKey, DBG_DESC
DevIndex = CInt("&amp;H" &amp; Mid(objItem.AssociationKey,6,4))
If Len(objItem.AssociationKey) &gt; 9 Then
DevCabinet = CInt("&amp;H" &amp; Mid(objItem.AssociationKey,16,4))
End If
componentNameArray(componentCount) = DevCabinet &amp; "/" &amp; DevIndex &amp; " " &amp; objItem.ElementName
Else
componentNameArray(componentCount) = objItem.ElementName
End If
If objItem.Presence = 1 Then
DebugOut "Component " &amp; index &amp; ": '" &amp; componentNameArray(componentCount) &amp; "', " &amp; objItem.HealthState &amp; " [" &amp; SCOM_HealthState(objItem.HealthState) &amp; "]", DBG_DATA
componentCount = componentCount + 1 ' we only count existing components
Else
componentCountEmpty = componentCountEmpty + 1
componentNameArray(componentCount) = ""
End If
index = index + 1
End If
Next
On Error Goto 0
End If
Else
If SVAgentRunning = true Then
SubSystem = scciHealthStateSubsystem(SubSystemNumber)
DebugOut "GetComponents for '" &amp; SubSystem &amp; "'", DBG_DATA
scciText = Split(SubSystem, " - ")

If SubSystemNumber = OTHER Then
componentNameArray(componentCount) = SVAgentOverallState
DebugOut "Component " &amp; componentCount &amp; ": " &amp; componentNameArray(componentCount), DBG_DATA
componentCount = componentCount + 1 ' we only count existing components

componentNameArray(componentCount) = SVCommunicationMonitor
DebugOut "Component " &amp; componentCount &amp; ": " &amp; componentNameArray(componentCount), DBG_DATA
componentCount = componentCount + 1

scciText = Split(scciHealthStateSubsystem(SELFTEST), " - ")
End If

sysNo = GetScciData(&amp;H2300, 0, 0, Cabinet)
DebugOut "Got " &amp; sysNo &amp; " Status Tree Subsystems", DBG_DESC
For i=0 To sysNo-1
scciName = GetScciData(&amp;H2302, i, 0, Cabinet)
DebugOut i &amp; " Subsystem: " &amp; scciName, DBG_DESC
If scciText(0) = scciName Then

subsysNo = GetScciData(&amp;H2305, i, 0, Cabinet)
DebugOut " Got " &amp; subsysNo &amp; " Status Tree Subsys Classes", DBG_DESC
For j=0 To subsysNo-1
scciName = GetScciData(&amp;H2307, i, j, Cabinet)
DebugOut " " &amp; i &amp; "/" &amp; j &amp; " SubsystemClass: " &amp; scciName, DBG_DESC
If scciText(1) = scciName Then

subsyscompWord = i * &amp;H10000 + j
subsyscompNo = GetScciData(&amp;H2320, subsyscompWord, 0, Cabinet)
DebugOut " Got " &amp; subsyscompNo &amp; " Status Tree Subsys Components", DBG_DESC
cab = 0
l = 0
For k=0 To subsyscompNo-1
If k &gt; cMAXINDEX Then
DebugOut "Max. no. of '" &amp; scciName &amp; "' instances (" &amp; cMAXINDEX &amp; ") reached/exceeded", DBG_DESC
Exit For
End If

scciState = oSwitch.VBRequest(&amp;H2322, subsyscompWord, l, CabinetArray(cab), 0, 0, 0, ret)
if ret &lt;&gt; 0 Then
DebugOut "oSwitch: No Data for opCode=0x" &amp; Hex(&amp;H2322) &amp; " opCodeExt=0x" &amp; Hex(subsyscompWord) &amp; " objIndex=" &amp; l &amp; " cabID=" &amp; CabinetArray(cab), DBG_DESC
cab = cab + 1
l = 0
scciState = oSwitch.VBRequest(&amp;H2322, subsyscompWord, l, CabinetArray(cab), 0, 0, 0, ret)
if ret &lt;&gt; 0 Then
DebugOut "oSwitch: No Data for opCode=0x" &amp; Hex(&amp;H2322) &amp; " opCodeExt=0x" &amp; Hex(subsyscompWord) &amp; " objIndex=" &amp; l &amp; " cabID=" &amp; CabinetArray(cab), DBG_DESC
Else
DebugOut "oSwitch: opCode=0x" &amp; Hex(&amp;H2322) &amp; " opCodeExt=0x" &amp; Hex(subsyscompWord) &amp; " objIndex=" &amp; l &amp; " cabID=" &amp; CabinetArray(cab) &amp; " -&gt; scciValue = '" &amp; scciState &amp; "'", DBG_DESC
End If
Else
DebugOut "oSwitch: opCode=0x" &amp; Hex(&amp;H2322) &amp; " opCodeExt=0x" &amp; Hex(subsyscompWord) &amp; " objIndex=" &amp; l &amp; " cabID=" &amp; CabinetArray(cab) &amp; " -&gt; scciValue = '" &amp; scciState &amp; "'", DBG_DESC
End If

scciDesc = GetScciData(&amp;H2324, subsyscompWord, l, CabinetArray(cab))
If SubSystemNumber = FANS Or SubSystemNumber = TEMPERATURE Or SubSystemNumber = POWERSUPPLY Then
componentNameArray(componentCount) = CabinetArray(cab) &amp; "/" &amp; l &amp; " " &amp; scciDesc
ElseIf SubSystemNumber = OTHER Then
componentNameArray(componentCount) = GetScciData(&amp;H2308, i, j, cab)
ElseIf SubSystemNumber = POWERCONSUMP Then
componentNameArray(componentCount) = "Power Level"
Else
componentNameArray(componentCount) = scciDesc
End If

If scciState &lt; 0 Or scciState &gt; 5 Then
componentStatusArray(componentCount) = STATUS_INVALID
Else
componentStatusArray(componentCount) = scciHealthStateString(scciState)
End If

If componentStatusArray(componentCount) &lt;&gt; STATUS_NOTPRESENT Then
DebugOut " " &amp; i &amp; "/" &amp; j &amp; "/" &amp; k &amp; ": SubSystemComponent: '" &amp; componentNameArray(componentCount) &amp; "', '" &amp; scciState &amp; "' [" &amp; componentStatusArray(componentCount) &amp; "]", DBG_DATA
componentCount = componentCount + 1 ' we only count existing components
Else
componentCountEmpty = componentCountEmpty + 1
componentNameArray(componentCount) = ""
componentStatusArray(componentCount) = ""
End If
l = l + 1
Next
j = subsysNo
i = sysNo
End If
Next
End If
Next
Else
DebugOut "Agent is *** NOT *** running ...", DBG_DATA
End If
End If

GetComponents = componentCount
End Function

'****************************************************************

Function CheckSavedComponents(componentSubSystemType, componentNumber)
DebugOut "Found '" &amp; componentNumber &amp; "' instances of component '" &amp; ComponentsStateList(componentSubSystemType) &amp; "' (was " &amp; ComponentsPYServerData(componentSubSystemType) &amp; ")", DBG_INFO

If CInt(ComponentsPYServerData(componentSubSystemType)) = CInt("-1") Then
componentNumber = SavePYServerData(ComponentsStateList(componentSubSystemType), componentNumber)
DebugOut "Added '" &amp; componentNumber &amp; "' *NEW* '" &amp; ComponentsStateList(componentSubSystemType) &amp; "' instances to discovered components.", DBG_INFO
Else
If CInt(componentNumber) &lt; CInt(ComponentsPYServerData(componentSubSystemType)) Then
If ComponentsPYServerDataValid(componentSubSystemType) &lt;&gt; "" Then
DebugOut "Missing '" &amp; ComponentsPYServerData(componentSubSystemType) - componentNumber &amp; "' instances of '" &amp; ComponentsStateList(componentSubSystemType) &amp; "' (expected '" &amp; ComponentsPYServerData(componentSubSystemType) &amp; "', found '" &amp; componentNumber &amp; "')!", DBG_INFO
' Do not save the new number of components.
' Admin must manually reset all saved component data to acknowledge missing components.
LogScriptEvent 250, ERROR_EVENT, "Missing '" &amp; ComponentsPYServerData(componentSubSystemType) - componentNumber &amp; "' instances of '" &amp; ComponentsStateList(componentSubSystemType) &amp; "' (expected '" &amp; ComponentsPYServerData(componentSubSystemType) &amp; "', found '" &amp; componentNumber &amp; "')!"
Else
DebugOut "*MAYBE* missing '" &amp; ComponentsPYServerData(componentSubSystemType) - componentNumber &amp; "' instances of '" &amp; ComponentsStateList(componentSubSystemType) &amp; "' (expected '" &amp; ComponentsPYServerData(componentSubSystemType) &amp; "', found '" &amp; componentNumber &amp; "')! Wait for next discovery to be sure.", DBG_INFO
SavePYServerData ComponentsStateList(componentSubSystemType) &amp; "Valid", "yes"
End If
componentNumber = ComponentsPYServerData(componentSubSystemType)
Else
If CInt(componentNumber) &gt; CInt(ComponentsPYServerData(componentSubSystemType)) Then
DebugOut "Found '" &amp; componentNumber - ComponentsPYServerData(componentSubSystemType) &amp; "' *ADDITIONAL* instances of '" &amp; ComponentsStateList(componentSubSystemType) &amp; "'.", DBG_INFO
LogScriptEvent 200, INFORMATIONAL_EVENT, "Found '" &amp; componentNumber - ComponentsPYServerData(componentSubSystemType) &amp; "' *ADDITIONAL* instances of '" &amp; ComponentsStateList(componentSubSystemType) &amp; "' (expected '" &amp; ComponentsPYServerData(componentSubSystemType) &amp; "', found '" &amp; componentNumber &amp; "')."
End If
If ComponentsPYServerDataValid(componentSubSystemType) &lt;&gt; "" Then
DeletePYServerData(ComponentsStateList(componentSubSystemType) &amp; "Valid")
End If
End If
DebugOut "Keep '" &amp; componentNumber &amp; "' '" &amp; ComponentsStateList(componentSubSystemType) &amp; "' instances for discovered components.", DBG_INFO
End If

CheckSavedComponents = componentNumber
End Function

'****************************************************************

Function GetiRMCDNSName
Dim BMCHttpPort, BMCHttpsPort, BMCHttpsEnabled
Dim BMCUseBmcName, BMCAddSerial, BMCAddExt, BMCNameExt, BMCBoardSerial, BMCMACAddrArr, BMCMACAddr
Dim BMCBmcName, iRMCDNSName, BMCDNSDomain
Dim i, Status, BMCError

BMCHttpsEnabled = GetScciData(&amp;HE001, &amp;H1425, &amp;H0, Cabinet)
DebugOut "BMC Https Enabled: " &amp; BMCHttpsEnabled, DBG_INFO

If BMCHttpsEnabled Then
BMCHttpsPort = GetScciData(&amp;HE001, &amp;H1421, &amp;H0, Cabinet)
DebugOut "BMC Https Port: " &amp; BMCHttpsPort, DBG_INFO
Else
BMCHttpPort = GetScciData(&amp;HE001, &amp;H1420, &amp;H0, Cabinet)
DebugOut "BMC Http Port: " &amp; BMCHttpPort, DBG_INFO
End If

BMCError = 0
BMCUseBmcName = GetScciData(&amp;HE001, &amp;H1431, &amp;H0, Cabinet)
If IsNull(BMCUseBmcName) Or Len(BMCUseBmcName) = 0 Then
BMCError = BMCError + 1
BMCUseBmcName = 0 'set to a defined / usable value
End If
DebugOut "Use Bmc Name = " &amp; isEnabled(BMCUseBmcName), DBG_INFO

BMCAddSerial = GetScciData(&amp;HE001, &amp;H1433, &amp;H0, Cabinet)
If IsNull(BMCAddSerial) Or Len(BMCAddSerial) = 0 Then
BMCError = BMCError + 1
BMCAddSerial = 0 'set to a defined / usable value
End If
DebugOut "Add Serial = " &amp; isEnabled(BMCAddSerial), DBG_INFO

If isEnabled(BMCAddSerial) = true Then
BMCMACAddrArr = oSwitch.VBRequest(&amp;HE001, &amp;H1445, 0, Cabinet, 0, 0, 0, Status)
If Status = 0 Then
DebugOut "oSwitch: opCode=0x" &amp; Hex(&amp;HE001) &amp; " opCodeExt=0x" &amp; Hex(&amp;H1445) &amp; " objIndex=" &amp; 0 &amp; " cabID=" &amp; Cabinet &amp; " -&gt; scciValue = '[Array]'", DBG_DESC
BMCMACAddr = ByteArrayToMAC(BMCMACAddrArr)
DebugOut "MAC address = " &amp; BMCMACAddr, DBG_INFO
BMCBoardSerial = ByteArrayToiRMCMACSerial(BMCMACAddrArr)
DebugOut "MAC 'serial' = " &amp; BMCBoardSerial, DBG_INFO
Else
DebugOut "oSwitch: No Data for opCode=0x" &amp; Hex(&amp;HE001) &amp; " opCodeExt=0x" &amp; Hex(&amp;H1445) &amp; " objIndex=" &amp; 0 &amp; " cabID=" &amp; Cabinet, DBG_DESC
DebugOut "Err.Number = " &amp; Err.Number, DBG_DATA
DebugOut "Status = " &amp; Status, DBG_DATA
BMCError = BMCError + 1
BMCAddSerial = false
End If
End If

BMCAddExt = GetScciData(&amp;HE001, &amp;H1434, &amp;H0, Cabinet)
If IsNull(BMCAddExt) Or Len(BMCAddExt) = 0 Then
BMCError = BMCError + 1
BMCAddExt = 0 'set to a defined / usable value
End If
DebugOut "Add Ext = " &amp; isEnabled(BMCAddExt), DBG_INFO

If isEnabled(BMCAddExt) = true Then
BMCNameExt = GetScciData(&amp;HE001, &amp;H1432, 0, Cabinet)
If IsNull(BMCNameExt) Or Len(BMCNameExt) = 0 Then
BMCError = BMCError + 1
BMCAddExt = false
BMCAddExt = ""
End If
DebugOut "BMC network name extension = " &amp; BMCNameExt, DBG_INFO
End If

If isEnabled(BMCUseBmcName) = true Then
BMCBmcName = GetScciData(&amp;HE001, &amp;H1430, 0, Cabinet)
If IsNull(BMCBmcName) Or Len(BMCBmcName) = 0 Then
BMCError = BMCError + 1
BMCBmcName = ""
End If
DebugOut "BMC network name = " &amp; BMCBmcName, DBG_INFO
Else
' misuse same variable holding the result ...
BMCBmcName = GetScciData(&amp;HE001, &amp;H0201, 0, Cabinet)
If IsNull(BMCBmcName) Or Len(BMCBmcName) = 0 Then
BMCError = BMCError + 1
BMCBmcName = ""
End If
DebugOut "system's node name = " &amp; BMCBmcName, DBG_INFO
End If

If BMCError &gt; 1 Then
GetiRMCDNSName = "N/A"
Else
' Strip whitespaces from Hostname
BMCBmcName = Trim(BMCBmcName)
BMCBmcName = Replace(BMCBmcName," ","-")
BMCBmcName = Replace(BMCBmcName,vbTab,"-")

' // Find "." in Hostname and terminate
i = inStr(BMCBmcName, ".")
If i = 0 Then
i = lenb(BMCBmcName)
End If
BMCBmcName = Left(BMCBmcName, i)
DebugOut "BMC name = '" &amp; BMCBmcName &amp; "'", DBG_INFO

If isEnabled(BMCAddSerial) = true Then
iRMCDNSName = BMCBmcName &amp; Trim(BMCBoardSerial)
Else
iRMCDNSName = BMCBmcName
End If
If isEnabled(BMCAddExt) = true Then
iRMCDNSName = iRMCDNSName &amp; Trim(BMCNameExt)
End If

' Again: Strip whitespaces from Hostname
iRMCDNSName = Trim(iRMCDNSName)
iRMCDNSName = Replace(iRMCDNSName," ","-")
iRMCDNSName = Replace(iRMCDNSName,vbTab,"-")

DebugOut "BMC DNS name = '" &amp; iRMCDNSName &amp; "'", DBG_INFO

BMCDNSDomain = GetScciData(&amp;HE001, &amp;H144D, 0, Cabinet)
If IsNull(BMCDNSDomain) Or Len(BMCDNSDomain) = 0 Then
DebugOut "BMC domain name not set!", DBG_INFO
BMCDNSDomain = ""
Else
iRMCDNSName = iRMCDNSName &amp; "." &amp; BMCDNSDomain
DebugOut "BMC DNS name = '" &amp; iRMCDNSName &amp; "'", DBG_INFO
End If

If BMCHttpsEnabled = 0 Then
If BMCHttpPort &lt;&gt; "" Then
GetiRMCDNSName = "http://" &amp; iRMCDNSName &amp; ":" &amp; BMCHttpPort
Else
GetiRMCDNSName = "http://" &amp; iRMCDNSName
End If
Else
If BMCHttpsPort &lt;&gt; "" Then
GetiRMCDNSName = "https://" &amp; iRMCDNSName &amp; ":" &amp; BMCHttpsPort
Else
GetiRMCDNSName = "https://" &amp; iRMCDNSName
End If
End If
End If

End Function

'****************************************************************

Function isEnabled(check)
isEnabled = false

If Len(check) &gt; 0 Then
If check = true Or check = 1 Then
isEnabled = true
End If
End If
End Function

'****************************************************************

Function ByteArrayToMAC(bytearray)

Dim B, I, J, temp
Redim B(lenb(bytearray)-1)

J = lenb(bytearray)
For I=1 to J
B(I-1) = right("0" &amp; hex(AscB(MidB(bytearray,I,1))),2)
Next
ByteArrayToMAC = B(0)
For I=2 to J
ByteArrayToMAC = ByteArrayToMAC &amp; ":" &amp; B(I-1)
Next

End Function

'****************************************************************

Function ByteArrayToiRMCMACSerial(bytearray)

Dim B, I, J, temp
Redim B(lenb(bytearray)-1)

J = lenb(bytearray)
For I=1 to J
B(I-1) = right("0" &amp; hex(AscB(MidB(bytearray,I,1))),2)
Next
ByteArrayToiRMCMACSerial = B(3)
For I=5 to J
ByteArrayToiRMCMACSerial = ByteArrayToiRMCMACSerial &amp; B(I-1)
Next

End Function

'****************************************************************

Sub CreateLogIniFile(LogIniFileDir)
Const SVISCOMLogIn_ = "SVISCOMLog.in_"
Const SEC_ServerDiscovery = "[ServerDiscovery]"
Const SEC_ComponentsMonitor = "[ComponentsMonitor]"
Const SEC_FCEvents = "[FCEvents]"
Const SEC_ResetPYServerData = "[ResetPYServerData]"
Const SEC_PerfMonMonitor = "[PerfMonMonitor]"

Const KEYVAL_DEBUGMODE = "DebugMode=true"
Const KEYVAL_DEBUGMODEALL = "DebugModeALL=true"
Const KEYVAL_OVERWRITE = "OverWrite=true"

Dim oTextStream, wTextStream 'As Scripting.TextStream
Dim LogIniFilePath
Dim thisLine, versionLine, pathOK, fileOK
Dim objItem

On Error Resume Next

DebugOut "Start CreateLogIniFile", DBG_INFO
fileOK = False
pathOK = False

LogIniFilePath = LogIniFileDir &amp; "\" &amp; SVISCOMLogIn_
If Not (oFSO.FileExists(LogIniFilePath)) Then
DebugOut LogIniFilePath &amp; " is not available.", DBG_INFO
If Not oFSO.FolderExists(LogIniFileDir) Then
DebugOut "Create " &amp; LogIniFileDir, DBG_INFO
oFSO.CreateFolder(LogIniFileDir)
Else
DebugOut LogIniFileDir &amp; " is available.", DBG_INFO
End If

If Not (oFSO.FolderExists(LogIniFileDir)) Then
DebugOut "Log file folder " &amp; LogIniFileDir &amp; " could not be created. Abort logging to file.", DBG_ALL
DebugFile = false
Else
pathOK = True
End If
Else
DebugOut LogIniFilePath &amp; " is available.", DBG_INFO
pathOK = True
Set oTextStream = oFSO.OpenTextFile(LogIniFilePath, 1, True)
Do While Not oTextStream.AtEndOfStream
thisLine = oTextStream.ReadLine
if InStr(thisLine, MPVERSION) Then
DebugOut "Found " &amp; MPVersion &amp; " in IN_ file.", DBG_INFO
fileOK = true
Exit Do
End If
Loop
oTextStream.Close
End If

' write new SVISCOMlog.in_ file
versionLine = "; SVISCOM Debug INI file for Windows MP Version " &amp; MPVERSION
If pathOK = true And fileOK = False Then
' we write a new SVISCOMLog.in_ file, every time the MP is changed to make sure all INI-Values
' are documented for use by the customer if anything changes.
Set oTextStream = oFSO.OpenTextFile(LogIniFilePath, 2, True) ' 2 = new file for writing
DebugOut "Create " &amp; LogIniFilePath, DBG_INFO
If Not IsNull(oTextStream) Then
DebugOut "Write values to " &amp; LogIniFilePath, DBG_INFO
oTextStream.WriteLine versionLine
oTextStream.WriteLine "; "
oTextStream.WriteLine "; With this file logging for all scripts within the management pack can be enabled."
oTextStream.WriteLine "; Each of the Sections in this file represents a script."
oTextStream.WriteLine "; DebugMode enables logging (true|yes|1) or "
oTextStream.WriteLine "; disables logging (false|no|0)"
oTextStream.WriteLine "; OverWrite defines continuous logging (false|no|0) or"
oTextStream.WriteLine "; single script run logging (true|yes|1)"
oTextStream.WriteLine "; To avoid huge log files the files are moved to a folder with the actual date as"
oTextStream.WriteLine "; name every 30 days if Overwrite is set to 'false'." &amp; vbCrLf

oTextStream.WriteLine "; Server Discovery Section"
oTextStream.WriteLine SEC_ServerDiscovery
oTextStream.WriteLine KEYVAL_DEBUGMODE
oTextStream.WriteLine KEYVAL_OVERWRITE &amp; vbCrLf
oTextStream.WriteLine "; Component Monitor Section"
oTextStream.WriteLine SEC_ComponentsMonitor
oTextStream.WriteLine KEYVAL_DEBUGMODEALL
oTextStream.WriteLine KEYVAL_OVERWRITE &amp; vbCrLf
oTextStream.WriteLine "; Fibre Channel Event Monitor Section"
oTextStream.WriteLine SEC_FCEvents
oTextStream.WriteLine KEYVAL_DEBUGMODE
oTextStream.WriteLine KEYVAL_OVERWRITE &amp; vbCrLf
oTextStream.WriteLine "; Reset PRIMERGY Server Data Section"
oTextStream.WriteLine SEC_ResetPYServerData
oTextStream.WriteLine KEYVAL_DEBUGMODE
oTextStream.WriteLine KEYVAL_OVERWRITE &amp; vbCrLf
oTextStream.WriteLine "; Performance Monitor Section"
oTextStream.WriteLine SEC_PerfMonMonitor
oTextStream.WriteLine KEYVAL_DEBUGMODE
oTextStream.WriteLine KEYVAL_OVERWRITE &amp; vbCrLf
oTextStream.Close
End If
End If

' this means a new SVISCOM MP has just been installed (SVISCOMlog.in_ had a other version)
If fileOK = False Then
DebugOut "New MPVersion V" &amp; MPVersion, DBG_INFO

' Remove any old Registry paths and values
Const regPath32_FSC = "SOFTWARE\Fujitsu Siemens\ServerView SCOM Integration\PYServerData"
Const regPath32_SCOMINTEG = "SOFTWARE\Fujitsu Siemens\ServerView SCOM Integration"
Const regPath64_FSC = "SOFTWARE\Wow6432Node\Fujitsu Siemens\ServerView SCOM Integration\PYServerData"
Const regPath64_SCOMINTEG = "SOFTWARE\Wow6432Node\Fujitsu Siemens\ServerView SCOM Integration"
Const regPath32_V7 = "SOFTWARE\Fujitsu\ServerView Suite\SCOM Integration\PYServerData"
Const regPath64_V7 = "SOFTWARE\Wow6432Node\Fujitsu\ServerView Suite\SCOM Integration\PYServerData"
Dim strValue
strValue = ""

Err.Clear()

'*** delete old FSC 32-bit reg path
Registry.GetStringValue HKEY_LOCAL_MACHINE, regPath32_FSC, "Manufacturer", strValue
If strValue &lt;&gt; "" Then
DebugOut "Found PY data in old FSC 32-bit registry path. Delete: " &amp; regPath32_FSC, DBG_INFO
Registry.DeleteKey HKEY_LOCAL_MACHINE, regPath32_FSC
Registry.DeleteKey HKEY_LOCAL_MACHINE, regPath32_SCOMINTEG
End If

'*** delete old FSC 64-bit reg path
Registry.GetStringValue HKEY_LOCAL_MACHINE, regPath64_FSC, "Manufacturer", strValue
If strValue &lt;&gt; "" Then
DebugOut "Found PY data in old FSC 64-bit registry path. Delete: " &amp; regPath64_FSC, DBG_INFO
Registry.DeleteKey HKEY_LOCAL_MACHINE, regPath64_FSC
Registry.DeleteKey HKEY_LOCAL_MACHINE, regPath64_SCOMINTEG
End If

'*** delete old V7 32-bit reg path
Registry.GetStringValue HKEY_LOCAL_MACHINE, regPath32_V7, "Manufacturer", strValue
If strValue &lt;&gt; "" Then
DebugOut "Found PY data in old V7 32-bit registry path. Delete: " &amp; regPath32_V7, DBG_INFO
Registry.DeleteKey HKEY_LOCAL_MACHINE, regPath32_V7
End If

'*** delete old V7 64-bit reg path
Registry.GetStringValue HKEY_LOCAL_MACHINE, regPath64_V7, "Manufacturer", strValue
If strValue &lt;&gt; "" Then
DebugOut "Found PY data in old V7 64-bit registry path. Delete: " &amp; regPath64_V7, DBG_INFO
Registry.DeleteKey HKEY_LOCAL_MACHINE, regPath64_V7
End If


' check for version in SVISCOMLog.ini and adapt if necessary
If oFSO.FileExists(LogIniFileDir &amp; "\" &amp; SVISCOMLogIniName) Then
DebugOut LogIniFileDir &amp; "\" &amp; SVISCOMLogIniName &amp; " is available.", DBG_INFO
oFSO.CopyFile LogIniFileDir &amp; "\" &amp; SVISCOMLogIniName, LogIniFileDir &amp; "\" &amp; SVISCOMLogIniName &amp; "_copy", 1
Set oTextStream = oFSO.OpenTextFile(LogIniFileDir &amp; "\" &amp; SVISCOMLogIniName &amp; "_copy", 1, True)
Set wTextStream = oFSO.OpenTextFile(LogIniFileDir &amp; "\" &amp; SVISCOMLogIniName, 2, True)
wTextStream.WriteLine versionLine
Do While Not oTextStream.AtEndOfStream
thisLine = oTextStream.ReadLine
' make sure to catch V7 typo "SVSICOM"
if InStr(thisLine, "SVISCOM") Or InStr(thisLine, "SVSICOM") Then
if InStr(thisLine, MPVersion) Then
DebugOut "Found correct " &amp; MPVersion &amp; " in INI file.", DBG_INFO
fileOK = true
End If
Else
wTextStream.WriteLine thisLine
End If
Loop
wTextStream.Close
oTextStream.Close
oFSO.DeleteFile LogIniFileDir &amp; "\" &amp; SVISCOMLogIniName &amp; "_copy", 1

' this really is a new MP
If fileOK = False Then
' Re-Initialize PY server data
DebugOut "Re-initialize PYServerData for V" &amp; MPVersion, DBG_INFO
For Each objItem In ComponentsStateList
Call SavePYServerData(objItem, -1)
Next
End If
End If
End If

On Error Goto 0

DebugOut "End CreateLogIniFile", DBG_INFO
End Sub

'****************************************************************

Sub AddMPElement(oInst, elementName, elementValue)
DebugOut "AddMPElement: '" &amp; elementName &amp; "' = '" &amp; elementValue &amp; "'", DBG_SCOM
Call oInst.AddProperty(elementName, "" &amp; elementValue)
End Sub

'****************************************************************

Sub AddObjectData(oInst, displayName, PrincipalName)
DebugOut "AddObjectData for '" &amp; displayName &amp; "' / '" &amp; PrincipalName &amp; "'", DBG_SCOM
AddMPElement oInst, "$MPElement[Name='System!System.Entity']/DisplayName$", displayName
AddMPElement oInst, "$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", PrincipalName
End Sub

'****************************************************************

Sub AddSoftwareData(oInst, displayName, swName, swVersion, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName)
AddObjectData oInst, displayName, PrincipalName
DebugOut "AddSoftwareData for '" &amp; displayName &amp; "'", DBG_SCOM
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.SimpleCollection']/NetworkName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='FTSLIB!Fujitsu.ServerView.ManagementSoftware']/Version$", swVersion
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ManagementClientSoftware']/Devices$", swName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ManagementClientSoftware']/ServerName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ManagementClientSoftware']/NetworkName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ManagementClientSoftware']/BMCAddrIPv4$", BMCIPv4Addr
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ManagementClientSoftware']/BMCAddr$", iRMCDNSName
End Sub

'****************************************************************

Sub AddSoftwareVersionData(oInst, deviceName, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName)
AddObjectData oInst, deviceName, PrincipalName
DebugOut "AddSoftwareVersionData for '" &amp; deviceName &amp; "'", DBG_SCOM
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ManagementClientSoftware']/NetworkName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.SimpleCollection']/NetworkName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/ServerName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/BMCAddrIPv4$", BMCIPv4Addr
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/BMCAddr$", iRMCDNSName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.OtherComponent']/Device$", deviceName
End Sub

'****************************************************************
Sub AddComponentData(oInst, componentSubSystemType, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager)
AddObjectData oInst, ComponentsList(componentSubSystemType), PrincipalName
DebugOut "AddComponentData for '" &amp; ComponentsList(componentSubSystemType) &amp; "'", DBG_SCOM
AddMPElement oInst, "$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$", componentNames
AddMPElement oInst, "$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", componentInfos
AddMPElement oInst, "$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.HealthCollection']/NetworkName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.HealthCollection']/BMCAddrIPv4$", BMCIPv4Addr
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.HealthCollection']/BMCAddr$", iRMCDNSName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.HealthCollection']/ComponentID$", ComponentsStateList(componentSubSystemType)
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.HealthCollection']/MonitoringAgents$", MonitoringAgents
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.HealthCollection']/RaidManager$", RaidManager
End Sub

'****************************************************************

Sub AddSimpleDeviceData(oInst, deviceName, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager)
AddObjectData oInst, deviceName, PrincipalName
DebugOut "AddSimpleDeviceData for '" &amp; deviceName &amp; "'", DBG_SCOM
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.HealthCollection']/NetworkName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/ServerName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/BMCAddrIPv4$", BMCIPv4Addr
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/BMCAddr$", iRMCDNSName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ComponentHealth']/Device$", deviceName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ComponentHealth']/MonitoringAgents$", MonitoringAgents
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ComponentHealth']/RaidManager$", RaidManager
End Sub

'****************************************************************

Sub AddOtherDeviceData(oInst, deviceName, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName)
AddObjectData oInst, deviceName, PrincipalName
DebugOut "AddOtherDeviceData for '" &amp; deviceName &amp; "'", DBG_SCOM
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.HealthCollection']/NetworkName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/ServerName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/BMCAddrIPv4$", BMCIPv4Addr
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/BMCAddr$", iRMCDNSName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.OtherComponent']/Device$", deviceName
End Sub

'****************************************************************

Sub AddRaidControllerData(oInst, displayName, deviceName, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName)
AddObjectData oInst, displayName, PrincipalName
DebugOut "AddRaidControllerData for '" &amp; deviceName &amp; "'", DBG_SCOM
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.HealthCollection']/NetworkName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/ServerName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/BMCAddrIPv4$", BMCIPv4Addr
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/BMCAddr$", iRMCDNSName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ComponentBundleHealth']/Device$", deviceName
End Sub

'****************************************************************

Sub AddRaidDeviceGroupData(oInst, displayName, deviceName, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName)
AddObjectData oInst, displayName, PrincipalName
DebugOut "AddRaidDeviceGroupData for '" &amp; displayName &amp; "'", DBG_SCOM
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.HealthCollection']/NetworkName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/ServerName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/BMCAddrIPv4$", BMCIPv4Addr
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/BMCAddr$", iRMCDNSName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.SimpleCollection']/NetworkName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ComponentBundleHealth']/Device$", deviceName
End Sub

'****************************************************************

Sub AddRaidDeviceData(oInst, displayname, adapterName, deviceName, PrincipalName, TargetComputer, BMCIPv4Addr, iRMCDNSName, MonitoringAgents, RaidManager)
AddObjectData oInst, displayname, PrincipalName
DebugOut "AddRaidDeviceData for '" &amp; displayname &amp; "'", DBG_SCOM
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.HealthCollection']/NetworkName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/ServerName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/BMCAddrIPv4$", BMCIPv4Addr
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.Component']/BMCAddr$", iRMCDNSName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ComponentHealth']/Device$", deviceName
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ComponentHealth']/MonitoringAgents$", MonitoringAgents
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ComponentHealth']/RaidManager$", RaidManager
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.SimpleCollection']/NetworkName$", TargetComputer
AddMPElement oInst, "$MPElement[Name='Fujitsu.Servers.PRIMERGY.Windows.ComponentBundleHealth']/Device$", adapterName
End Sub

'****************************************************************
'****************************************************************
'****************************************************************

'-------------------------------------------------------------------
' Main.vbs
'-------------------------------------------------------------------
Main
</Script></Contents>
</File>
</Files>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>