Fujitsu Out-Of-Band Server Discovery

Fujitsu.Servers.PRIMERGY.OutOfBand.ServerDiscovery (Discovery)

Discovery for the Fujitsu Out-Of-Band Server and its components.

Knowledge Base article:

Summary

Server Discovery discovers all Fujitsu Out-Of-Band Servers and components via the integrated Remote Management Controller iRMC S4/S5.

Element properties:

TargetFujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice
EnabledTrue
Frequency14400
RemotableFalse
CommentDiscovers all Fujitsu Out-Of-Band Servers and components

Object Discovery Details:

Discovered Classes and their attribuets:
Discovered relationships and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Fujitsu.Servers.PRIMERGY.OutOfBand.ServerDiscoveryDataSource Default

Source Code:

<Discovery ID="Fujitsu.Servers.PRIMERGY.OutOfBand.ServerDiscovery" Target="iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice" Enabled="true" ConfirmDelivery="false" Remotable="true" Priority="Normal" Comment="Discovers all Fujitsu Out-Of-Band Servers and components">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ProcessorGroup">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup" PropertyID="ID"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="ServerName"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="Devices"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="DevicesInfo"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Processor">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Processor" PropertyID="L3Cache"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Processor" PropertyID="L2Cache"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Processor" PropertyID="L1Cache"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Processor" PropertyID="MaxClockSpeed"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Processor" PropertyID="NumPhysicalCores"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Processor" PropertyID="NumLogicalCores"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Processor" PropertyID="Manufacturer"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Processor" PropertyID="Model"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryGroup">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup" PropertyID="ID"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="ServerName"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="Devices"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="DevicesInfo"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule" PropertyID="ConfigStatus"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule" PropertyID="RevisionCode"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule" PropertyID="SerialNumber"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule" PropertyID="PartNumber"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule" PropertyID="Voltage"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule" PropertyID="BusFrequency"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule" PropertyID="ManufacturingDate"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule" PropertyID="Manufacturer"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule" PropertyID="Size"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule" PropertyID="Type"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.FanGroup">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup" PropertyID="ID"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="ServerName"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="Devices"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="DevicesInfo"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Fan">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupplyGroup">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup" PropertyID="ID"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="ServerName"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="Devices"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="DevicesInfo"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply" PropertyID="Model"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply" PropertyID="Manufacturer"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply" PropertyID="ManufacturingDate"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply" PropertyID="PartNumber"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply" PropertyID="SerialNumber"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply" PropertyID="Version"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard" PropertyID="Model"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard" PropertyID="Manufacturer"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard" PropertyID="ManufacturingDate"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard" PropertyID="PartNumber"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard" PropertyID="SerialNumber"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard" PropertyID="Version"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupplyNotPresent">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent" PropertyID="Status"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModuleNotPresent">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent" PropertyID="Status"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModuleNotUsable">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModuleNotUsable" PropertyID="ConfigStatus"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ProcessorNotPresent">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent" PropertyID="Status"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.FanNotPresent">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent" PropertyID="Status"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PciSlotNotPresent">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent" PropertyID="SensorType"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent" PropertyID="EntityId"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent" PropertyID="EntityInstance"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent" PropertyID="ManagementUrl"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent" PropertyID="Status"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.DriveSlotNotPresent">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent" PropertyID="SensorType"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent" PropertyID="EntityId"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent" PropertyID="EntityInstance"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent" PropertyID="ManagementUrl"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent" PropertyID="Status"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.BXServer">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="BmcFirmware"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="SystemFirmware"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="Manufacturer"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ManufacturingDate"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ChassisModel"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="PartNumber"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ManagementUrl"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="PhysicalMemory"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.Server" PropertyID="NetworkName"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="Model"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="SerialNumber"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="OperatingSystem"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.CXServer">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="BmcFirmware"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="SystemFirmware"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="Manufacturer"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ManufacturingDate"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ChassisModel"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="PartNumber"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ManagementUrl"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="PhysicalMemory"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.Server" PropertyID="NetworkName"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="Model"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="SerialNumber"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="OperatingSystem"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.RXServer">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="BmcFirmware"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="SystemFirmware"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="Manufacturer"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ManufacturingDate"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ChassisModel"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="PartNumber"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ManagementUrl"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="PhysicalMemory"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.Server" PropertyID="NetworkName"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="Model"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="SerialNumber"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="OperatingSystem"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.SXServer">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="BmcFirmware"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="SystemFirmware"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="Manufacturer"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ManufacturingDate"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ChassisModel"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="PartNumber"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ManagementUrl"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="PhysicalMemory"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.Server" PropertyID="NetworkName"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="Model"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="SerialNumber"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="OperatingSystem"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.TXServer">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="BmcFirmware"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="SystemFirmware"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="Manufacturer"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ManufacturingDate"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ChassisModel"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="PartNumber"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ManagementUrl"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="PhysicalMemory"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.Server" PropertyID="NetworkName"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="Model"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="SerialNumber"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="OperatingSystem"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.XXServer">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="BmcFirmware"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="SystemFirmware"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="Manufacturer"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ManufacturingDate"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ChassisModel"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="PartNumber"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="ManagementUrl"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.Server" PropertyID="PhysicalMemory"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.Server" PropertyID="NetworkName"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="Model"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="SerialNumber"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.System" PropertyID="OperatingSystem"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup" PropertyID="ID"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusTemperatureGroup">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusTemperatureGroup" PropertyID="ID"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="ServerName"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="Devices"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="DevicesInfo"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusVoltageGroup">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusVoltageGroup" PropertyID="ID"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="ServerName"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="Devices"/>
<Property TypeID="FTSLIB!Fujitsu.ServerView.HealthCollection" PropertyID="DevicesInfo"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusDriveSlotGroup">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusDriveSlotGroup" PropertyID="ID"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPciSlotGroup">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPciSlotGroup" PropertyID="ID"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.VoltageComponentStatus">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="SensorType"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityId"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityInstance"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.BatteryComponentStatus">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="SensorType"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityId"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityInstance"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.TemperatureComponentStatus">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="SensorType"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityId"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityInstance"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.AirInletComponentStatus">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="SensorType"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityId"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityInstance"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.DriveSlotComponentStatus">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="SensorType"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityId"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityInstance"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PciSlotComponentStatus">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="SensorType"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityId"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityInstance"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.BiosComponentStatus">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="SensorType"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityId"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityInstance"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtCtrlComponentStatus">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="SensorType"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityId"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityInstance"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtSoftwareComponentStatus">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="SensorType"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityId"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityInstance"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PowerMonitoringComponentStatus">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="SensorType"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityId"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityInstance"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PowerUnitComponentStatus">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="SensorType"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityId"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityInstance"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatus">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ID"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="SensorType"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityId"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="EntityInstance"/>
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus" PropertyID="ManagementUrl"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.CommunicationMonitor">
<Property TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.CommunicationMonitor" PropertyID="ID"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsProcessorGroup"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ProcessorGroupHostsProcessor"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ProcessorGroupHostsProcessorNotPresent"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsMemoryGroup"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryGroupHostsMemory"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryGroupHostsMemoryNotPresent"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryGroupHostsMemoryNotUsable"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsPowerSupplyGroup"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupplyGroupHostsPowerSupply"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupplyGroupHostsPowerSupplyNotPresent"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsFanGroup"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.FanGroupHostsFan"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.FanGroupHostsFanNotPresent"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsMainboard"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsTemperatureComponentGroup"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsVoltageComponentGroup"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsOtherComponentStatusGroup"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsDriveSlotComponentGroup"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsPciSlotComponentGroup"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsMgmtSoftwareComponentGroup"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsPowerUnitComponentGroup"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsBiosComponentStatus"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsMgmtCtrlComponentStatus"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsPowerMonitoringComponentStatus"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsOtherComponentStatus"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.TemperatureStatusGroupHostsTemperatureComponentStatus"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.VoltageStatusGroupHostsVoltageComponentStatus"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.DriveSlotStatusGroupHostsDriveSlotComponentStatus"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.DriveSlotStatusGroupHostsDriveSlotNotPresent"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PciSlotStatusGroupHostsPciSlotComponentStatus"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PciSlotStatusGroupHostsPciSlotNotPresent"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtSoftwareStatusGroupHostsMgmtSoftwareComponentStatus"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.PowerUnitStatusGroupHostsPowerUnitComponentStatus"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.iRMCDeviceHostsServer"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsCommunicationMonitor"/>
<DiscoveryRelationship TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.MainboardReferencesVoltageComponentGroup"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Fujitsu.Servers.PRIMERGY.OutOfBand.ServerDiscoveryDataSource" Comment="Fujitsu Out-Of-Band Server Discovery uses the iRMC System Report data">
<!-- Note: default every 4 hours -->
<IntervalSeconds>14400</IntervalSeconds>
<!-- Note: spread discovery of multiple instances over 15 minutes -->
<SpreadInitializationOverInterval>900</SpreadInitializationOverInterval>
<ScriptName>ServerDiscovery.ps1</ScriptName>
<ScriptBody><Script>
##################################################################################
# #
# NOTICE #
# #
# COPYRIGHT 2015 - 2018 FUJITSU LIMITED #
# ALL RIGHTS RESERVED #
# #
# This computer program is CONFIDENTIAL and contains TRADE SECRETS of #
# FUJITSU LIMITED. The receipt or possession of this program does #
# not convey any rights to reproduce or disclose its contents, or to #
# manufacture, use, or sell anything that it may describe, in whole or #
# in part, without the specific written consent of FUJITSU LIMITED. #
# Any reproduction of this program without the express written consent #
# of FUJITSU LIMITED is a violation of the copyright laws and may #
# subject you to civil liability and criminal prosecution. #
# #
##################################################################################


param(
[string]$IP,
[int] $Port,
[string]$UserName,
[string]$Password,
[string]$SkipCACheck = "False",
[string]$SkipCNCheck = "False",
[int] $TimeoutSeconds = 300,

[string]$UseDnsNameAsNetworkName = "False",
[string]$UseDnsNameAsDisplayName = "False",

[string]$IncludeNotPresentProcessors = "True",
[string]$IncludeNotPresentFans = "True",
[string]$IncludeNotPresentPowerSupplies = "True"

)

$ScriptApi = New-Object -comObject "MOM.ScriptAPI"
if ($ScriptApi -eq $Null) { Exit -1 }

$discoveryData = $ScriptApi.CreateDiscoveryData(0, "$MPElement$", "$Target/Id$")

# set CONSTANT variables (can not be changed):
set-variable -name PoShScriptName -value "ServerDiscovery.ps1" -option constant

[int]$ERROR_UNSUPPORTED_FIRMWARE = 8009 # a prime

[int]$SCRIPT_EVENT_NUMBER = 8017 # a prime

# Note: Keep in sync with monitoring scripts
[int]$ERROR_MEMORY_INFORMATION_NOT_INITIALIZED = 8039 # a prime
[int]$ERROR_NO_FAN_INFORMATION = 8049 # not a prime
[int]$ERROR_NO_MEMORY_INFORMATION = 8059 # a prime
[int]$ERROR_NO_PROCESSOR_INFORMATION = 8069 # a prime
[int]$ERROR_NO_POWER_SUPPLY_INFORMATION = 8079 # not a prime
[int]$ERROR_NO_COMPONENT_STATUS_INFORMATION = 8089 # a prime

[int]$ERROR_NO_CONFIG_INFORMATION = 8123 # a prime
[int]$ERROR_NO_USERNAME = 8199 # not a prime


# we need to make multiple authenticated HTTP requests...
[System.Net.NetworkCredential]$NetworkCredential = New-Object System.Net.NetworkCredential ($username, $password)
[System.Net.ServicePointManager]::DefaultConnectionLimit = 1000

[bool]$script:iRMCDetected = $False
[bool]$script:HpSimValid = $False

# Note: Keep in sync with cookdown monitoring script (Host_ID)
$ProcessorGroupName = 'Processors'
$MemoryGroupName = 'Memory'
$FanGroupName = 'Fans (Cooling)'
$PowerSupplyGroupName = 'Power Supplies'
$MainboardName = 'Mainboard'

[xml]$xml = New-Object XML
[System.Xml.XmlElement]$elem = $Null

$BmcFirmwareVersion = "N/A"
$BiosVersion = "N/A"

# Server Properties
$ServerModel = "N/A"
$ServerSerialNumber = "N/A"
$ServerPartNumber = "N/A"
$ServerManufacturer = "N/A"
$ServerManufacturingDate = "N/A"
$ServerUuid = "N/A"
$ServerOperatingSystem = "N/A"
$SvAgentVersion = "N/A"

# System Board Properties
$BoardModel = "N/A"
$BoardVersion = "N/A"
$BoardSerialNumber = "N/A"
$BoardPartNumber = "N/A"
$BoardManufacturer = "N/A"
$BoardManufacturingDate = "N/A"

# Chassis Properties
$ChassisModel = "N/A"
$ChassisSerialNumber = "N/A"
$ChassisPartNumber = "N/A"

$OtherComponentsGroupInstance = $Null

$ServerDnsName = "N/A"
$ServerDnsDomain = "N/A"
$NetworkName = $IP # default to IP Address
$DnsName = $IP # default to IP Address

# Strip any potential garbage at the and of the XML string
Function Clean-XmlString ([string]$xmlString, [string]$endTag) {
if ($xmlString.contains( $endTag )) {
$xmlString.TrimEnd( $xmlString.Substring( ($xmlString.IndexOf($endTag) +$endTag.Length) ))
} else {
$xmlString
}
}

# Due to various problems we support iRMC S4 firmware 8.2x and later (e.g. 8.23F)
# Note: internal pre-releases are marked as 96.xx / 97.xx / 98.xx / 99.xx and are considered unsupported
# Note: iRMC S5 have different firmware numbering schema
Function FirmwareVersionSupported ([string]$Version)
{
# iRMC S4
if ( ($Version -match "^8.([2-9][0-9])") -or ($Version -match "^9.([0-9][0-9])") -or ($Version -match "^[1-8][0-9].([0-9][0-9])")) {
return $True
}

# iRMC S5 re-started version numbering from 1.xx
# Note: There is another Redfish specific version check in the iRMC Extended Device discovery
if ( ($Version -match "^1.([0-9][0-9])") ) {
return $True
}

# Enable debug / intermediate builds
#if ( ($Version -match "^9[0-9].([0-9][0-9])") ) {
# return $True
#}

return $False
}

# Check if there is already an existing iRMC object for this discovery.
# If so, mark discovery
Function BailOutAndTestForExisting
{
CloseRedfishSession

# Load Extensions
$OMPSInstallKey = "HKLM:\Software\Microsoft\System Center Operations Manager\12\Setup\Powershell\V2"
$regKey = get-item $OMPSInstallKey
$OMPSInstallPath = $regKey.GetValue("InstallDirectory")
$omModule = $OMPSInstallPath + "OperationsManager"
Import-Module -Name $omModule

# Make sure we use empty discovery data (or else 10003 events will be generated)
$discoveryData = $ScriptApi.CreateDiscoveryData(0, "$MPElement$", "$Target/Id$")
$discoveryData.IsSnapshot = $True # default to not found ...
try {
$MyObj = Get-SCOMClass -Name 'Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice' | Get-SCOMClassInstance | Where {$_.'[Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice].IP'.Value -eq $IP}
if ($MyObj -ne $Null) {
DebugOut "$IP - Found existing SCOM object - marking discovery incomplete..."
$discoveryData.IsSnapshot = $False
} else {
DebugOut "$IP - NOT found as existing SCOM object - giving up"
}
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Could not determine existing object. Exception: $_"
}

$discoveryData
Exit
}

# Totally unsupported
Function BailOut
{
CloseRedfishSession
$discoveryData.IsSnapshot = $True
$discoveryData
Exit
}

# something went wrong
Function EarlyExit
{
CloseRedfishSession
$discoveryData.IsSnapshot = $False
$discoveryData
Exit
}


Function CloseRedfishSession
{
# Close Redfish session if we opened one
if ( ![String]::IsNullOrEmpty($script:RedfishSession) ) {
try {
DebugOut "$IP - Delete Redfish session '$($script:RedfishSession)'"
(doWebRequest -url "$hostURL$($script:RedfishSession)" -Method "DELETE" -XAuthData $script:AuthData) | Out-Null
} catch {}
}
}


Function Redfish_Main {

DebugOut "$IP - Discovery for Fujitsu Out-Of-Band Server (Redfish) - start"

$ServiceRoot = $Null
try {
# Note: According to the specification the ServiceRoot should be available unauthenticated;
# but older firmware versions (e.g. iRMC S4 with firmware 8.4x) do not support this or do not know this URL.
# In order to properly detect these systems (and abort), use the provided/available credentials
#$ServiceRoot = (doWebRequest -url "$hostURL/redfish/v1" -Method "GET" -Credentials $Null -XAuthData $Null) | ConvertFrom-JSON
$ServiceRoot = (doWebRequest -url "$hostURL/redfish/v1" -Method "GET" -Credentials $NetworkCredential -XAuthData $Null) | ConvertFrom-JSON
if ($ServiceRoot) {
DebugOut "$IP - '$($ServiceRoot.Name)' Redfish Version=$($ServiceRoot.RedfishVersion) UUID: $($ServiceRoot.UUID)"
if ($ServiceRoot.'@odata.etag' -eq $Null -or $ServiceRoot.'@odata.etag' -eq '') {
DebugOut "$IP - Seems to be an old Redfish instrumentation, giving up..."
return
}
} else {
DebugOut "$IP - Could not get Service Root, giving up."
return
}
} catch {
DebugWarn "$IP - Error getting Service Root, Exception: $_"
return
}

# Get the Redfish System and Chassis Information
try {
$script:RedfishSession = $Null
if ($UseRedfishSession -eq $True) {
DebugOut "$IP - try to create a new Redfish session..."
$SessionEntry = (doWebRequest -url "$hostURL$($ServiceRoot.Links.Sessions.'@odata.id')" -Credentials $Null -XAuthData $Null -Method "POST" -RequestData "{'UserName':'$($UserName)','Password':'$($Password)'}" ) | ConvertFrom-JSON

if (!$SessionEntry) {
DebugOut "$IP - Could not create session"
return
}

if ($SessionEntry.Error) {
DebugWarn "$IP - ERROR creating session: ErrorCode='$($SessionEntry.Error.code)' Message='$($SessionEntry.Error.message)'"
return
}

if ($SessionEntry.'@odata.id' -ne '') {
DebugOut "`tSession Id=$($SessionEntry.Id) '$($SessionEntry.'@odata.id')'"
$script:RedfishSession = $SessionEntry.'@odata.id'
} else {
DebugWarn "`tSession Id=$($SessionEntry.Id) - no link"
}
}

#############################################################################################
$NetworkName = $IP # default is plain IP until otherwise proven

$Systems = $Null
if ($ServiceRoot -and $ServiceRoot.Systems.'@odata.id') {
$Systems = (doWebRequest -url "$hostURL$($ServiceRoot.Systems.'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON
if ($Systems -and $Systems.'[email protected]' -gt 0) {
if ($Systems.'[email protected]' -gt 1) {
DebugOut "$IP - has Information for $($Systems.'[email protected]') Systems..."
}

for ($SystemIdx = 0; $SystemIdx -lt $Systems.'[email protected]'; $SystemIdx++) {
# Note: Modeling multiple systems under one IP Address is currently not planned
if (($Systems.'[email protected]' -gt 1) -and ($SystemIdx -gt 0)) {
DebugOut "$IP - System $($SystemIdx) : Information"
DebugOut "$IP - Multi System Configurations are currently unsupported - IGNORING"
continue
}

$SystemRoot = (doWebRequest -url "$hostURL$($Systems.Members[$SystemIdx].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON
if ($SystemRoot) {
DebugOut "$IP - is a $($SystemRoot.Manufacturer) '$($SystemRoot.Model)' Description='$($SystemRoot.Description)' AssetTag='$($SystemRoot.AssetTag)' Serial='$($SystemRoot.SerialNumber)' PartNumber='$($SystemRoot.PartNumber)'"
DebugOut "$IP - System HostName='$($SystemRoot.HostName)' UUID='$($SystemRoot.UUID)' Indicator LED is '$($SystemRoot.IndicatorLED)'"
DebugOut "$IP - System Status: PowerState='$($SystemRoot.PowerState)' Health='$($SystemRoot.Status.Health)' State='$($SystemRoot.Status.State)' HealthRollup='$($SystemRoot.Status.HealthRollup)' "

if ($SystemRoot.PowerState -eq 'Off') {
DebugOut "$IP - System Power State is '$($SystemRoot.PowerState)' - aborting discovery"
BailOutAndTestForExisting
}

$ServerModel = $SystemRoot.Model
$BiosVersion = $SystemRoot.BiosVersion

# Get iRMC Firmware Version info
if ($SystemRoot.Oem.ts_fujitsu) {
$FirmwareInventory = $SystemRoot.Oem.ts_fujitsu.FirmwareInventory
if ($FirmwareInventory -ne $Null -and $FirmwareInventory.'@odata.id' -ne '') {
$Inventory = (doWebRequest -url "$hostURL$($FirmwareInventory.'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON
if ($Inventory) {
DebugOut "$IP - iRMC Firmware='$($Inventory.BMCFirmware)' BuildDate='$($Inventory.BMCFirmwareBuildDate)' Running='$($Inventory.BMCFirmwareRunning)' SDR Version='$($Inventory.SDRRVersion)' SDRRId='$($Inventory.SDRRId)' BIOS='$($Inventory.SystemBIOS)'"
$BmcFirmwareVersion = $Inventory.BMCFirmware
}
}

$Mainboard = $SystemRoot.Oem.ts_fujitsu.Mainboard
if ($Mainboard -ne $Null) {
DebugOut "$IP - Mainboard Manufacturer='$($Mainboard.Manufacturer)' Model='$($Mainboard.Model)' Serial='$($Mainboard.SerialNumber)' PartNumber='$($Mainboard.PartNumber)' Version='$($Mainboard.Version)'"
}

# Other OEM System Information
$OemSystem = $SystemRoot.Oem.ts_fujitsu.System
if ($OemSystem -ne $Null -and $OemSystem.'@odata.id' -ne '') {
$OemSystemInfo = (doWebRequest -url "$hostURL$($OemSystem.'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON
if ($OemSystemInfo) {
DebugOut "'$IP' Agent Version='$($OemSystemInfo.AgentVersion)' Agent Type='$($OemSystemInfo.AgentType)' (SNMP) Sys Location='$($OemSystemInfo.Location)' Contact='$($OemSystemInfo.Contact)' "
DebugOut "'$IP' SystemName='$($OemSystemInfo.SystemName)' Operating System='$($OemSystemInfo.OperatingSystem)' Version='$($OemSystemInfo.OperatingSystemVersion)' SystemIP='$($OemSystemInfo.SystemIP)' "
if ( ![String]::IsNullOrEmpty($OemSystemInfo.OperatingSystem) ) {
$ServerOperatingSystem = $OemSystemInfo.OperatingSystem
}
if ( ![String]::IsNullOrEmpty($OemSystemInfo.AgentVersion) ) {
# We do not differentiate between 'Management Agent' and 'Agentless Service' (or ESXi CIM Providers)
$SvAgentVersion = $OemSystemInfo.AgentVersion
}

}
}

}

DebugOut "$IP - 'Managed By' Information:"
for ($Idx=0; $Idx -lt $SystemRoot.Links.'[email protected]'; $Idx++) {
$Manager = (doWebRequest -url "$hostURL$($SystemRoot.Links.ManagedBy[$Idx].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON
if ($Manager) {
# $Manager.Name is currently Fixed to 'Manager'
DebugOut "`t'$($Manager.Name)': Model='$($Manager.Model)' Type='$($Manager.ManagerType)' FirmwareVersion='$($Manager.FirmwareVersion)' UUID='$($Manager.UUID)' Health='$($Manager.Status.Health)' HealthRollup='$($Manager.Status.HealthRollup)' State='$($Manager.Status.State)'"

$Services = @('CommandShell', 'SerialConsole', 'GraphicalConsole')
foreach ($Service in $Services.GetEnumerator()) {
if ($Manager -and $Manager.$($Service)) {
DebugOut "`t'$($Manager.Model)': Service '$($Service)' Enabled=$($Manager.$($Service).ServiceEnabled) MaxSessions=$($Manager.$($Service).MaxConcurrentSessions) Connect Types Supported='$($Manager.$($Service).ConnectTypesSupported[0])'"
}
}

if ($Manager -and $Manager.EthernetInterfaces) {
$Collection = (doWebRequest -url "$hostURL$($Manager.EthernetInterfaces.'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON
if ($Collection) {
DebugOut "`t'$($Collection.Name)': Collection has $($Collection.'[email protected]') Member(s):"
if ($Collection -and $($Collection.'[email protected]') -gt 0) {
for ($i = 0; $i -lt $Collection.'[email protected]'; $i++) {
$SubItem = (doWebRequest -url "$hostURL$($Collection.Members[$i].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON
if ($SubItem) {
DebugOut "`t`t'$($SubItem.Name)': MACAddress'$($SubItem.MACAddress)' Enabled=$($SubItem.InterfaceEnabled) HostName='$($SubItem.HostName)' FQDN=$($SubItem.FQDN)' Health='$($SubItem.Status.Health)' State='$($SubItem.Status.State)'"
for ($j=0; $j -lt $SubItem.IPv4Addresses.Count; $j++) {
DebugOut "`t`t'$($SubItem.Name)': IPv4 Address=$($SubItem.IPv4Addresses[$j].Address) Netmask=$($SubItem.IPv4Addresses[$j].SubnetMask) Gateway=$($SubItem.IPv4Addresses[$j].Gateway) ($($SubItem.IPv4Addresses[$j].AddressOrigin))"
}
for ($j=0; $j -lt $SubItem.IPv6Addresses.Count; $j++) {
DebugOut "`t`t'$($SubItem.Name)': IPv6 Address=$($SubItem.IPv6Addresses[$j].Address)/$($SubItem.IPv6Addresses[$j].PrefixLength) ($($SubItem.IPv6Addresses[$j].AddressOrigin)) AddressState=$($SubItem.IPv6Addresses[$j].AddressState)"
}
if ($SubItem.Oem.ts_fujitsu) {
$OemExt = $SubItem.Oem.ts_fujitsu
DebugOut "`t`t'$($SubItem.Name)': Add OEM Ethernet Interface Stuff here ..."
}
}
}
}
}
}

# Not a collection - see http://redfish.dmtf.org/schemas/ManagerNetworkProtocol.v1_1_0.json
if ($Manager -and $Manager.NetworkProtocol) {
$Item = (doWebRequest -url "$hostURL$($Manager.NetworkProtocol.'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON
if ($Item) {
DebugOut "`t'$($Item.Name)' HostName='$($Item.HostName)' FQDN='$($Item.FQDN)' Health='$($Item.Status.Health)' State='$($Item.Status.State)'"
if ( ![String]::IsNullOrEmpty($Item.FQDN) ) {
$DnsName = $Item.FQDN
}

$Protocols = @('HTTP', 'HTTPS', 'SNMP', 'IPMI', 'SSH', 'Telnet', 'SSDP', 'KVMIP', 'VirtualMedia')
foreach ($Protocol in $Protocols.GetEnumerator()) {
if ($Item -and $Item.$($Protocol)) {
DebugOut "`t`t'$($Item.Name)': $($Protocol) Enabled='$($Item.$($Protocol).ProtocolEnabled)' Port=$($Item.$($Protocol).Port)"
}
}

}
}
}
}


DebugOut "$IP - Chassis Information:"
$ChassisRoot = (doWebRequest -url "$hostURL$($SystemRoot.Links.Chassis[0].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON
if ($ChassisRoot) {
DebugOut "$IP - Chassis Type='$($ChassisRoot.ChassisType)' Model='$($ChassisRoot.Model)' from $($ChassisRoot.Manufacturer) AssetTag='$($ChassisRoot.AssetTag)' Serial='$($ChassisRoot.SerialNumber)' PartNumber='$($ChassisRoot.PartNumber)'"
DebugOut "$IP - Chassis Power State is '$($ChassisRoot.PowerState)' Chassis Indicator LED is '$($ChassisRoot.IndicatorLED)'"
DebugOut "$IP - Chassis Status: Health='$($ChassisRoot.Status.Health)' HealthRollup='$($ChassisRoot.Status.HealthRollup)' State='$($ChassisRoot.Status.State)' "
if ($ChassisRoot.Oem.ts_fujitsu) {
$OemChassis=$ChassisRoot.Oem.ts_fujitsu
DebugOut "$IP - Chassis OEM Image='$($OemChassis.Type)' CSS LED='$($OemChassis.CssLED)' GlobalError LED='$($OemChassis.GelLED)' VendorSpecific='$($OemChassis.VendorSpecificInformation)'"
}
}


# We have all information we need, create discovered Instances
$bmcInstance = $discoveryData.CreateClassInstance("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']$")
$bmcInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # key
$discoveryData.AddInstance($bmcInstance)

if ($ServerModel -ne "N/A") {
if ($ServerModel -match "PRIMERGY BX" ) {
$serverInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.BXServer']$")
} elseif ($ServerModel -match "PRIMERGY CX" ) {
$serverInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.CXServer']$")
} elseif ($ServerModel -match "PRIMERGY RX" ) {
$serverInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.RXServer']$")
} elseif ($ServerModel -match "PRIMERGY SX" ) {
$serverInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.SXServer']$")
} elseif ($ServerModel -match "PRIMERGY TX" ) {
$serverInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.TXServer']$")
} else { # Any other: use generic XX Type
$serverInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.XXServer']$")
}
} else {
DebugOut "$IP - Could not determine Server Model!"
$serverInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.XXServer']$")
}

$serverInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host

if ($UseDnsNameAsNetworkName -eq $True) {
$NetworkName = $DnsName
$serverInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $DnsName) # key
} else {
$serverInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $IP) # key
}
if ($UseDnsNameAsDisplayName -eq $True) {
$ServerName = $DnsName
} else {
$ServerName = $IP
}
$serverInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.System']/Model$", $SystemRoot.Model)
$serverInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.System']/SerialNumber$", $SystemRoot.SerialNumber)
$serverInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.System']/OperatingSystem$", $ServerOperatingSystem)
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/ManagementUrl$", $hostURL)
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/BmcFirmware$", $BmcFirmwareVersion)
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/Manufacturer$", $SystemRoot.Manufacturer)
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/ManufacturingDate$", 'N/A' ) # $SystemRoot.ManufacturingDate
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/PartNumber$", $SystemRoot.PartNumber)
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/ChassisModel$", $ChassisRoot.Model)
if ($BiosVersion -ne $Null -and $BiosVersion -ne "") {
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/SystemFirmware$", $SystemRoot.BiosVersion)
}
if ($SvAgentVersion -ne "N/A") {
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/AgentVersion$" , $SvAgentVersion)
}

$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/PhysicalMemory$", ([string]$SystemRoot.MemorySummary.TotalSystemMemoryGiB +" GB" ))
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/DnsName$", $DnsName)
$serverInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $ServerName)
$discoveryData.AddInstance($serverInstance)

# BMC hosts Out-Of-Band Server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.iRMCDeviceHostsServer']$")
$relationship.Source = $bmcInstance
$relationship.Target = $serverInstance
$discoveryData.AddInstance($relationship)

# Communication Monitor
$commName = 'Communication Monitor'
$commInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.CommunicationMonitor']$")
# key(s) of hosting chain object(s)
$commInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$commInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$commInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.CommunicationMonitor']/ID$", $commName)
$commInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $commName)
$discoveryData.AddInstance($commInstance)

# Communication Component hosted by Server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsCommunicationMonitor']$")
$relationship.Source = $serverInstance
$relationship.Target = $commInstance
$discoveryData.AddInstance($relationship)

try {
if ($Mainboard -ne $Null) {
$DisplayName = $MainboardName

$mainBoardModel = "N/A"
$mainBoardVersion = "N/A"
$mainBoardSerialNumber = "N/A"
$mainBoardPartNumber = "N/A"
$mainBoardManufacturer = "N/A"
$mainBoardManufacturingDate = "N/A" # Not supported on redfish
if ( ![String]::IsNullOrEmpty($Mainboard.Manufacturer) ) { $mainBoardManufacturer = $Mainboard.Manufacturer }
if ( ![String]::IsNullOrEmpty($Mainboard.Model) ) { $mainBoardModel = $Mainboard.Model }
if ( ![String]::IsNullOrEmpty($Mainboard.SerialNumber) ) { $mainBoardSerialNumber = $Mainboard.SerialNumber }
if ( ![String]::IsNullOrEmpty($Mainboard.PartNumber) ) { $mainBoardPartNumber = $Mainboard.PartNumber }
if ( ![String]::IsNullOrEmpty($Mainboard.Version) ) { $mainBoardVersion = $Mainboard.Version }

$mainBoardInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard']$")

# key(s) of hosting chain object(s)
$mainBoardInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$mainBoardInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)

$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ID$", $DisplayName) # key
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ManagementUrl$", $hostURL)
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ServerName$", $ServerName)
# Mainboard is Oem defined
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ODataType$", $SystemRoot.Oem.ts_fujitsu.'@odata.type')
# Note: Mainboard has no specific @odata.id and is part of the System Oem structure
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ODataId$", $SystemRoot.'@odata.id' +"#/Oem/ts_fujitsu/Mainboard")

$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard']/Model$" , $mainBoardModel)
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard']/Manufacturer$" , $mainBoardManufacturer)
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard']/ManufacturingDate$", $mainBoardManufacturingDate)
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard']/PartNumber$" , $mainBoardPartNumber)
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard']/SerialNumber$" , $mainBoardSerialNumber)
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard']/Version$" , $mainBoardVersion)

$mainBoardInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($mainBoardInstance)

# Mainboard hosted by server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsMainboard']$")
$relationship.Source = $serverInstance
$relationship.Target = $mainBoardInstance
$discoveryData.AddInstance($relationship)
}
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Mainboard Discovery: Exception=$_"
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("Fujitsu Out-Of-Band Server Mainboard Discovery: Exception=$_ ")
}

# Processors
if ($SystemRoot -and $SystemRoot.Processors.'@odata.id' -ne '') {
DebugOut "$IP - Processor Information ..."
$Items = (doWebRequest -url "$hostURL$($SystemRoot.Processors.'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON
if ($Items) {
DebugOut "$IP - has $($Items.'[email protected]') Processor Items:"

# Create Processor Group
$groupName = $ProcessorGroupName
$cpuGroupInst = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ProcessorGroup']$")
$cpuGroupInst.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$cpuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # key of hosting object
$cpuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$" , $IP)

$cpuGroupInst.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)
$cpuGroupInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $groupName)

# HealthCollection Class Properties: Get List of devices
$Devices = "Processors: $($Items.'[email protected]')"
$DevicesInfo = ""

for ($idx = 0; $idx -lt $Items.'[email protected]'; $idx++) {
$Item = (doWebRequest -url "$hostURL$($Items.Members[$idx].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON
if ($Item) {
# Note: $Item.Socket contains the correct SDR Name, $Item.Name is fixed to 'CPU NN'
$DisplayName = $Item.Socket

if ($Item.Status.State -and $Item.Status.State -ne 'Absent') {
DebugOut "$IP -`t'$($DisplayName)': Model='$($Item.Model)' MaxSpeed=$($Item.MaxSpeedMHz) Cores=$($Item.TotalCores) Threads=$($Item.TotalThreads) Health='$($Item.Status.Health)' State='$($Item.Status.State)'"
# Build DevicesInfo
$DevicesInfo += "$($idx): '$($DisplayName)' '$($Item.Model)' Phys. Cores: $($Item.TotalCores), Log. Threads: $($Item.TotalThreads); "

$L1Cache = 'N/A'
$L2Cache = 'N/A'
$L3Cache = 'N/A'

if ($Item.Oem.ts_fujitsu) {
$OemExt = $Item.Oem.ts_fujitsu
DebugOut "$IP -`t'$($DisplayName)': Cache L1=$($OemExt.L1CacheKiB)KB L2=$($OemExt.L2CacheKiB)KB L3=$($OemExt.L3CacheKiB)KB TDP=$($OemExt.MaxTDPWatt) Watt CSS='$($OemExt.CssComponent)'"

try {
if ([int]$OemExt.L1CacheKiB -gt 1024) {
if ([int]$OemExt.L1CacheKiB % 1024 -eq 0) {
$L1Cache = "{0:d} MByte" -f ([int]$OemExt.L1CacheKiB/1024)
} else {
$L1Cache = "{0:f2} MByte" -f ([double]$OemExt.L1CacheKiB/1024)
}
} else {
$L1Cache = "$($OemExt.L1CacheKiB) KByte"
}
} catch {}

try {
if ([int]$OemExt.L2CacheKiB -gt 1024) {
if ([int]$OemExt.L2CacheKiB % 1024 -eq 0) {
$L2Cache = "{0:d} MByte" -f ([int]$OemExt.L2CacheKiB/1024)
} else {
$L2Cache = "{0:f2} MByte" -f ([double]$OemExt.L2CacheKiB/1024)
}
} else {
$L2Cache = "$($OemExt.L2CacheKiB) KByte"
}
} catch {}

try {
if ([int]$OemExt.L3CacheKiB -gt 1024) {
if ([int]$OemExt.L3CacheKiB % 1024 -eq 0) {
$L3Cache = "{0:d} MByte" -f ([int]$OemExt.L3CacheKiB/1024)
} else {
$L3Cache = "{0:f2} MByte" -f ([double]$OemExt.L3CacheKiB/1024)
}
} else {
$L3Cache = "$($OemExt.L3CacheKiB) KByte"
}
} catch {}
}

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']$")

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ODataType$", $Item.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ODataId$", $Item.'@odata.id')

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/Model$" , $Item.Model)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/Manufacturer$" , $Item.Manufacturer)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/NumLogicalCores$" , $Item.TotalThreads)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/NumPhysicalCores$", $Item.TotalCores)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/MaxClockSpeed$" , $Item.MaxSpeedMHz)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/L1Cache$" , $L1Cache)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/L2Cache$" , $L2Cache)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/L3Cache$" , $L3Cache)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)

$discoveryData.AddInstance($instance)

# Processor Group hosts Processor
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ProcessorGroupHostsProcessor']$")
$relationship.Source = $cpuGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} else {
DebugOut "$IP -`t'$($Item.Socket)': State='$($Item.Status.State)' (N/A)"
if ($IncludeNotPresentProcessors -eq $True) {
$DevicesInfo += "$($idx): '$($Item.Socket)' (Empty socket); "

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ProcessorNotPresent']$")

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent']/Status$", "CPU not installed")
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Group hosts Non Present component
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ProcessorGroupHostsProcessorNotPresent']$")
$relationship.Source = $cpuGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
}
}

# Update
$cpuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$" , $Devices)
$cpuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", $DevicesInfo)
$discoveryData.AddInstance($cpuGroupInst)

# Processor Group hosted by Server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsProcessorGroup']$")
$relationship.Source = $serverInstance
$relationship.Target = $cpuGroupInst
$discoveryData.AddInstance($relationship)

}
} else {
DebugWarn "$IP - NO Processor Information available..."
}

# Memory Modules
if ($SystemRoot -and $SystemRoot.Memory.'@odata.id' -ne '') {
DebugOut "$IP - Memory Information ..."
# HealthCollection Class Properties: Get List of devices
# try to match other MP's Device and Device Info
$Devices = "N/A"
$DevicesInfo = ""

# Build Device Info (list and count of size XX memory modules)
$index = 0
$mem_types = @{}

$Items = (doWebRequest -url "$hostURL$($SystemRoot.Memory.'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON
if ($Items) {
DebugOut "$IP - has $($Items.'[email protected]') Memory Items:"

# Memory Group
$groupName = $MemoryGroupName
$memGroupInst = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryGroup']$")
$memGroupInst.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host
$memGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host

$memGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$" , $IP)
$memGroupInst.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)
$memGroupInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $groupName)

for ($idx = 0; $idx -lt $Items.'[email protected]'; $idx++) {
$Item = (doWebRequest -url "$hostURL$($Items.Members[$idx].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON

if ($Item) {
if ( $Item.Status.State -and $Item.Status.State -ne 'Absent' ) {
# Note: $Item.DeviceLocator contains the correct SDR Name, $Item.Name is fixed to 'DIMM NN'
DebugOut "$IP -`t'$($Item.DeviceLocator)' $($Item.OperatingSpeedMhz)MHz $($Item.MemoryDeviceType)/$($Item.BaseModuleType) Manufacturer='$($Item.Manufacturer)' Serial='$($Item.SerialNumber)' PartNumber='$($Item.PartNumber)' Health='$($Item.Status.Health)' State='$($Item.Status.State)'"

$DisplayName = $Item.DeviceLocator
$MemSize = 'N/A'
$index++

try {
if ([int]$Item.CapacityMiB -lt 1024) {
$MemSize = "{0:d} MByte" -f ([int]$Item.CapacityMiB)
} else {
if ([int]$Item.CapacityMiB % 1024 -eq 0) {
$MemSize = "{0:d} GByte" -f ([int]$Item.CapacityMiB/1024)
} else {
$MemSize = "{0:f2} GByte" -f ([double]$Item.CapacityMiB/1024)
}
}

if ($mem_types.ContainsKey($MemSize)) {
$count = $mem_types.Get_Item($MemSize) + 1
$mem_types.Set_Item($MemSize, $count)
} else {
$mem_types.Add($MemSize, 1)
}

} catch {}

if ($Item.Oem.ts_fujitsu.ConfigurationState -ne 'Not usable') {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']$")

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host host
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName) #host

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ODataType$", $Item.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ODataId$", $Item.'@odata.id')

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/Type$" , $Item.MemoryDeviceType +" / " +$Item.BaseModuleType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/Size$" , $MemSize)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/BusFrequency$" , $Item.OperatingSpeedMhz)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/Voltage$" , $Item.Oem.ts_fujitsu.Voltage)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/Manufacturer$" , $Item.Manufacturer)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/ManufacturingDate$", $Item.Oem.ts_fujitsu.ManufacturingDate)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/PartNumber$" , $Item.PartNumber)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/SerialNumber$" , $Item.SerialNumber)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/RevisionCode$" , 'N/A') #$Item.ModuleRevisionCode

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/ConfigStatus$" , $Item.Oem.ts_fujitsu.ConfigurationState)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Memory Group hosts memory
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryGroupHostsMemory']$")
$relationship.Source = $memGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} else {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModuleNotUsable']$")

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ServerName$", $ServerName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModuleNotUsable']/ConfigStatus$", 'Not usable') # $Item.Oem.ts_fujitsu.ConfigurationState
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Memory Group hosts not usable memory
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryGroupHostsMemoryNotUsable']$")
$relationship.Source = $memGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

}

} else {
DebugOut "$IP -`t'$($Item.DeviceLocator)': State='$($Item.Status.State)' (N/A)"
}
}
}

if ($index -ne 0) {
$Devices = "Memory Modules: $($index)"
$DevicesInfo += "Memory Types: "
foreach ($key in $mem_types.Keys) {
$DevicesInfo += "'$($key)': $($mem_types[$key]), "
}
} else {
# No valid module information detected (BMC has not gotten any information from BIOS during POST)
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_MEMORY_INFORMATION_NOT_INITIALIZED -Message ("Memory Information not initialized - please reboot the Fujitsu Out-Of-Band Server")
DebugWarn "$IP - Memory Information not initialized - please reboot the Fujitsu Out-Of-Band Server"
}

$memGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$" , $Devices)
$memGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", $DevicesInfo)
$discoveryData.AddInstance($memGroupInst)

# Memory Group hosted by Server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsMemoryGroup']$")
$relationship.Source = $serverInstance
$relationship.Target = $memGroupInst
$discoveryData.AddInstance($relationship)

}
} else {
DebugOut "$IP - NO Memory Information available..."
}

# Fan and Power Supply Information are available in the Chassis Information
if ($ChassisRoot) {
if ($ChassisRoot.Thermal.'@odata.id' -ne '') {
DebugOut "$IP - Chassis 'Thermal' Information:"
$ThermalRoot = (doWebRequest -url "$hostURL$($ChassisRoot.Thermal.'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON
&lt;#
if ($ThermalRoot -and $ThermalRoot.'[email protected]' -gt 0) {
for ($idx = 0; $idx -lt $ThermalRoot.'[email protected]'; $idx++) {
$Item = $ThermalRoot.Temperatures[$idx]
if ($Item -and $Item.Status.State -ne 'UnavailableOffline') {
if ($Item.Oem.ts_fujitsu) {
DebugOut "$IP - Temperature '$($Item.Name)': PhysicalContext='$($Item.PhysicalContext)' SensorNumber=$($Item.SensorNumber) EntityId='$($Item.Oem.ts_fujitsu.EntityId)' EntityInstance=$($Item.Oem.ts_fujitsu.EntityInstance) Value=$($Item.ReadingCelsius)&#xB0;C UpperWarn=$($Item.UpperThresholdNonCritical)&#xB0;C UpperCrit=$($Item.UpperThresholdCritical)&#xB0;C Health='$($Item.Status.Health)' State='$($Item.Status.State)' LegacyStatus='$($Item.Oem.ts_fujitsu.LegacyStatus)'"
} else {
DebugOut "$IP - Temperature '$($Item.Name)': PhysicalContext='$($Item.PhysicalContext)' SensorNumber=$($Item.SensorNumber) Value=$($Item.ReadingCelsius)&#xB0;C UpperWarn=$($Item.UpperThresholdNonCritical)&#xB0;C UpperCrit=$($Item.UpperThresholdCritical)&#xB0;C Health='$($Item.Status.Health)' State='$($Item.Status.State)'"
}
} else {
if ($Item.Oem.ts_fujitsu) {
DebugOut "$IP - Temperature '$($Item.Name)': N/A - PhysicalContext='$($Item.PhysicalContext)' SensorNumber=$($Item.SensorNumber) EntityId='$($Item.Oem.ts_fujitsu.EntityId)' EntityInstance=$($Item.Oem.ts_fujitsu.EntityInstance) UpperWarn=$($Item.UpperThresholdNonCritical)&#xB0;C UpperCrit=$($Item.UpperThresholdCritical)&#xB0;C Health='$($Item.Status.Health)' State='$($Item.Status.State)' LegacyStatus='$($Item.Oem.ts_fujitsu.LegacyStatus)'"
} else {
DebugOut "$IP - Temperature '$($Item.Name)': N/A - PhysicalContext='$($Item.PhysicalContext)' SensorNumber=$($Item.SensorNumber) UpperWarn=$($Item.UpperThresholdNonCritical)&#xB0;C UpperCrit=$($Item.UpperThresholdCritical)&#xB0;C Health='$($Item.Status.Health)' State='$($Item.Status.State)'"
}
}
}
}
#&gt;
if ($ThermalRoot -and $ThermalRoot.'[email protected]' -gt 0) {

DebugOut "$IP - has $($ThermalRoot.'[email protected]') Fans"
# Fan Group
$groupName = $FanGroupName
$fanGroupInst = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.FanGroup']$")
$fanGroupInst.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host
$fanGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host

$fanGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$" , $IP)
$fanGroupInst.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)
$fanGroupInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $groupName)

# HealthCollection Class Properties: Get List of devices
$Devices = "Fan Devices: $($ThermalRoot.'[email protected]')"
$DevicesInfo = ""

for ($idx = 0; $idx -lt $ThermalRoot.'[email protected]'; $idx++) {
$Item = $ThermalRoot.Fans[$idx]
if ($Item) {
$DisplayName = $Item.Name
if ($Item.Status.State -and $Item.Status.State -ne 'UnavailableOffline' -and $Item.Status.State -ne 'Absent') {
if ($Item.Oem.ts_fujitsu) {
DebugOut "$IP -`t'$($Item.Name)': PhysicalContext='$($Item.PhysicalContext)' EntityId='$($Item.Oem.ts_fujitsu.EntityId)' EntityInstance=$($Item.Oem.ts_fujitsu.EntityInstance) Health='$($Item.Status.Health)' State='$($Item.Status.State)' LegacyStatus='$($Item.Oem.ts_fujitsu.LegacyStatus)'"
} else {
DebugOut "$IP -`t'$($Item.Name)': PhysicalContext='$($Item.PhysicalContext)' Health='$($Item.Status.Health)' State='$($Item.Status.State)'"
}

$DevicesInfo += "$($idx): '$($DisplayName)'; "

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Fan']$")

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host host
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName) # host

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ODataType$", $ThermalRoot.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ODataId$", $ChassisRoot.Links.CooledBy[$idx].'@odata.id')

$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Fan Group hosts Fan
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.FanGroupHostsFan']$")
$relationship.Source = $fanGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} else {
DebugOut "$IP -`t'$($Item.Name)': State='$($Item.Status.State)' (N/A)"
if ($IncludeNotPresentFans -eq $True) {
$DevicesInfo += "$($idx): '$($DisplayName)' Fan not installed; "
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.FanNotPresent']$")

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host host
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName) # host

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent']/Status$", "Fan not installed")
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Group hosts Non Present component
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.FanGroupHostsFanNotPresent']$")
$relationship.Source = $fanGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}

}
}
}

$fanGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$" , $Devices)
$fanGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", $DevicesInfo)
$discoveryData.AddInstance($fanGroupInst)

# Fan Group hosted by Server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsFanGroup']$")
$relationship.Source = $serverInstance
$relationship.Target = $fanGroupInst
$discoveryData.AddInstance($relationship)

}
}

if ($ChassisRoot.Power.'@odata.id' -ne '') {
DebugOut "$IP - Chassis 'Power' Information:"
$PowerRoot = (doWebRequest -url "$hostURL$($ChassisRoot.Power.'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData) | ConvertFrom-JSON
if ($PowerRoot) {
&lt;#
# Voltages
if ($PowerRoot.'[email protected]' -gt 0) {
for ($idx = 0; $idx -lt $PowerRoot.'[email protected]'; $idx++) {
$Item = $PowerRoot.Voltages[$idx]
if ($Item -and $Item.Status.State -ne 'UnavailableOffline') {
DebugOut "`tVoltage '$($Item.Name)': PhysicalContext='$($Item.PhysicalContext)' SensorNumber=$($Item.SensorNumber) Value=$($Item.ReadingVolts)V Health='$($Item.Status.Health)' State='$($Item.Status.State)'"
DebugOut "`t`tThresholds: UpperWarn=$($Item.UpperThresholdNonCritical) UpperCrit=$($Item.UpperThresholdCritical) / LowerWarn=$($Item.LowerThresholdNonCritical) LowerCrit=$($Item.LowerThresholdCritical)"
} else {
DebugOut "`tVoltage '$($Item.Name)': N/A - PhysicalContext='$($Item.PhysicalContext)' SensorNumber=$($Item.SensorNumber) LegacyStatus='$($Item.Oem.ts_fujitsu.LegacyStatus)'"
}
}
}
#&gt;
# PowerSupplies
if ($PowerRoot.'[email protected]' -gt 0) {
DebugOut "$IP - has $($PowerRoot.'[email protected]') Power Supplies"
# Power Supplies Group
$groupName = $PowerSupplyGroupName
$psuGroupInst = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupplyGroup']$")

$psuGroupInst.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host
$psuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host

$psuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$" , $IP)
$psuGroupInst.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)
$psuGroupInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $groupName)

# HealthCollection Class Properties: Get List of devices
$Devices = "Power Supplies: $($PowerRoot.'[email protected]')"
$DevicesInfo = ""

for ($idx = 0; $idx -lt $PowerRoot.'[email protected]'; $idx++) {
$Item = $PowerRoot.PowerSupplies[$idx]
if ($Item) {
$DisplayName = $Item.Name

$PsuModel = "N/A"
$PsuVersion = "N/A"
$PsuSerialNumber = "N/A"
$PsuPartNumber = "N/A"
$PsuManufacturer = "N/A"
$PsuManufacturingDate = "N/A" # Not supported on redfish
$PsuNominalPower = "N/A" # $Item.PowerCapacityWatts

if ( ![String]::IsNullOrEmpty($Item.Manufacturer) ) { $PsuManufacturer = $Item.Manufacturer }
if ( ![String]::IsNullOrEmpty($Item.Model) ) { $PsuModel = $Item.Model }
if ( ![String]::IsNullOrEmpty($Item.FirmwareVersion) ) { $PsuVersion = $Item.FirmwareVersion }
if ( ![String]::IsNullOrEmpty($Item.SerialNumber) ) { $PsuSerialNumber = $Item.SerialNumber }
if ( ![String]::IsNullOrEmpty($Item.PartNumber) ) { $PsuPartNumber = $Item.PartNumber }
if ( ![String]::IsNullOrEmpty($Item.ManufacturingDate) ) { $PsuManufacturingDate = $Item.ManufacturingDate }
if ( ![String]::IsNullOrEmpty($Item.PowerCapacityWatts) ) { $PsuNominalPower = [string]$Item.PowerCapacityWatts +" Watt" }


if ($Item.Status.State -and $Item.Status.State -ne 'UnavailableOffline' -and $Item.Status.State -ne 'Absent') {
DebugOut "$IP -`t'$($Item.Name)': Model='$($Item.Model)' Manufacturer='$($Item.Manufacturer)' Serial='$($Item.SerialNumber)' PartNumber='$($Item.PartNumber)' Firmware='$($Item.FirmwareVersion)' NominalPower=$($PsuNominalPower) Health='$($Item.Status.Health)' State='$($Item.Status.State)'"
$DevicesInfo += "$($idx): '$($DisplayName)'; "

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']$")
# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host host
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName) # host

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ODataType$", $PowerRoot.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ODataId$", $ChassisRoot.Links.PoweredBy[$idx].'@odata.id')

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']/Model$" , $PsuModel)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']/Version$" , $PsuVersion)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']/Manufacturer$" , $PsuManufacturer)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']/ManufacturingDate$", $PsuManufacturingDate)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']/PartNumber$" , $PsuPartNumber)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']/SerialNumber$" , $PsuSerialNumber)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']/NominalPower$" , $PsuNominalPower)

$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# PSU Group hosts PSU
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupplyGroupHostsPowerSupply']$")
$relationship.Source = $psuGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} else {
DebugOut "$IP -`t'$($Item.Name)': State='$($Item.Status.State)' (N/A)"
if ($IncludeNotPresentPowerSupplies -eq $True) {
$DevicesInfo += "$($idx): '$($DisplayName)' PSU not installed; "
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupplyNotPresent']$")

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent']/Status$", "PSU not installed")
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Group hosts Non Present component
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupplyGroupHostsPowerSupplyNotPresent']$")
$relationship.Source = $psuGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
}
}

$psuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$" , $Devices)
$psuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", $DevicesInfo)
$discoveryData.AddInstance($psuGroupInst)

# Power Supply Group hosted by Server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsPowerSupplyGroup']$")
$relationship.Source = $serverInstance
$relationship.Target = $psuGroupInst
$discoveryData.AddInstance($relationship)

}
}
}

}

# In Redfish Component Status instances are pre-sorted arrays per Sensor Type Type/Entity ID
DebugOut "$IP - Component Status Information ..."
$ComponentRoot = (doWebRequest -url "$hostURL/redfish/v1/Chassis/0/Oem/ts_fujitsu/ComponentStatus" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData ) | ConvertFrom-JSON
if ($ComponentRoot) {

$TotalComponentStati = 0;
$TotalComponentStati += [int] $ComponentRoot.'[email protected]'
$TotalComponentStati += [int] $ComponentRoot.'[email protected]'
$TotalComponentStati += [int] $ComponentRoot.'[email protected]'
$TotalComponentStati += [int] $ComponentRoot.'[email protected]'
DebugOut "$IP - Ignoring $($ComponentRoot.'[email protected]') Processor Component Status instances..."
DebugOut "$IP - Ignoring $($ComponentRoot.'[email protected]') Memory Component Status instances..."
DebugOut "$IP - Ignoring $($ComponentRoot.'[email protected]') Cooling Component Status instances..."
DebugOut "$IP - Ignoring $($ComponentRoot.'[email protected]') PSU Component Status instances..."

$OtherComponentsGroupDisplayName = "Other Component Status"
$OtherComponentsGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']$")
$OtherComponentsGroupInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host
$OtherComponentsGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host
$OtherComponentsGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName) # key
$OtherComponentsGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $OtherComponentsGroupDisplayName)
$discoveryData.AddInstance($OtherComponentsGroupInstance)

# Server hosts 'Other component status' group
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsOtherComponentStatusGroup']$")
$relationship.Source = $serverInstance
$relationship.Target = $OtherComponentsGroupInstance
$discoveryData.AddInstance($relationship)

# Also we know there are always some voltage component status instances (e.g. 'Batt 3.0V' and others)
$voltageComponentGroupDisplayName = "Voltage Component Status"
$voltageComponentGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusVoltageGroup']$")
$voltageComponentGroupInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host
$voltageComponentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host

$voltageComponentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$" , $IP)
# $voltageComponentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$" , "Voltage Component Status:")
# $voltageComponentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", "N/A")

$voltageComponentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusVoltageGroup']/ID$", $voltageComponentGroupDisplayName ) # key
$voltageComponentGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $voltageComponentGroupDisplayName)

# We also know there are always some Temperature Component Status instances (e.g. 'Ambient' Temperature and others)
$temperatureComponentGroupDisplayName = "Temperature Component Status"
$temperatureComponentGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusTemperatureGroup']$")
$temperatureComponentGroupInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host
$temperatureComponentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host

$temperatureComponentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$" , $IP)
# $temperatureComponentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$" , "Temperature Component Status:")
# $temperatureComponentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", "N/A")
$temperatureComponentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusTemperatureGroup']/ID$", $temperatureComponentGroupDisplayName ) # key
$temperatureComponentGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $temperatureComponentGroupDisplayName)

$VoltageDevices = 0
$VoltageDevicesInfo = ""

$TemperatureDevices = 0
$TemperatureDevicesInfo = ""

# Ambient Component Status is a Temperature Sensor Instance
if ($ComponentRoot.'[email protected]' -gt 0) {
DebugOut "$IP - has $($ComponentRoot.'[email protected]') Ambient Component Status Instance(s):"
for ($idx=0; $idx -lt $ComponentRoot.'[email protected]'; $idx++) {
$Component = (doWebRequest -url "$hostURL$($ComponentRoot.AmbientSensors[$idx].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData ) | ConvertFrom-JSON
if ($Component) {
DebugOut "$IP -`t'$($Component.Designation)' SensorType='$($Component.SensorType)' EntityID='$($Component.EntityId)' Instance=$($Component.EntityInstance) Status='$($Component.SignalStatus)' LED='$($Component.IdentifyLED)' CSS='$($Component.CssComponent)'"
$TemperatureDevicesInfo += "$($TemperatureDevices): '$($Component.Designation)'; "
$TotalComponentStati++
$TemperatureDevices++

$DisplayName = $Component.Designation
$EntityIdString = $Component.EntityId
$EntityInstance = $Component.EntityInstance

# Workaround for early instrumentation
if ($EntityInstance -eq '@SENSOR_GET_ENTITY_INSTANCE@') {
$EntityInstance = [string]$i
}
# Workaround for early instrumentation
if ([String]::IsNullOrEmpty($Component.SensorType)) {
$SensorType = 'Temperature'
} else {
$SensorType = $Component.SensorType
}
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.TemperatureComponentStatus']$")
# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host host
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusTemperatureGroup']/ID$", $temperatureComponentGroupDisplayName ) # host

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataType$", $Component.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataId$", $Component.'@odata.id')

$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.TemperatureStatusGroupHostsTemperatureComponentStatus']$")
$relationship.Source = $temperatureComponentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
}

# Same for Battery Component Status Instances (Voltages)
if ($ComponentRoot.'[email protected]' -gt 0) {
DebugOut "$IP - has $($ComponentRoot.'[email protected]') 'Battery Sensor' Component Status Instance(s):"
for ($i=0; $i -lt $ComponentRoot.'[email protected]'; $i++) {
$Component = (doWebRequest -url "$hostURL$($ComponentRoot.BatterySensors[$i].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData ) | ConvertFrom-JSON
if ($Component) {
DebugOut "$IP -`t'$($Component.Designation)' SensorType='$($Component.SensorType)' EntityID='$($Component.EntityId)' Instance=$($Component.EntityInstance) Status='$($Component.SignalStatus)' LED='$($Component.IdentifyLED)' CSS='$($Component.CssComponent)'"
$TotalComponentStati++
$VoltageDevicesInfo += "$($VoltageDevices): '$($Component.Designation)'; "
$VoltageDevices++

$DisplayName = $Component.Designation
$EntityIdString = $Component.EntityId
$EntityInstance = $Component.EntityInstance
# Workaround for early instrumentation
if ($EntityInstance -eq '@SENSOR_GET_ENTITY_INSTANCE@') {
$EntityInstance = [string]$i
}
# Workaround for early instrumentation
if ([String]::IsNullOrEmpty($Component.SensorType)) {
$SensorType = 'Voltage'
} else {
$SensorType = $Component.SensorType
}

if ($Component.SignalStatus -ne "EmptyOrNotInstalled") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.BatteryComponentStatus']$")
# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusVoltageGroup']/ID$", $voltageComponentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataType$", $Component.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataId$", $Component.'@odata.id')
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.VoltageStatusGroupHostsBatteryComponentStatus']$")
$relationship.Source = $voltageComponentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} else {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.BatteryNotPresent']$")
# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusVoltageGroup']/ID$", $voltageComponentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/EntityId$", $EntityIdString) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/EntityInstance$", $EntityInstance) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ServerName$", $ServerName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/Status$", $Status)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.VoltageStatusGroupHostsBatteryNotPresent']$")
$relationship.Source = $voltageComponentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
}
}

# System Component Status instances:
# depending on the firmware these list instances with EntityID = System (new), e.g. 'Temp' and 'Voltages'
# or the BIOS Component Status with EntityID = System Firmware (BIOS/EFI)
if ($ComponentRoot.'[email protected]' -gt 0) {
DebugOut "$IP - has $($ComponentRoot.'[email protected]') 'System' Component Status Instance(s):"
for ($i=0; $i -lt $ComponentRoot.'[email protected]'; $i++) {
$Component = (doWebRequest -url "$hostURL$($ComponentRoot.SystemSensors[$i].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData ) | ConvertFrom-JSON
if ($Component) {
DebugOut "$IP -`t'$($Component.Designation)' SensorType='$($Component.SensorType)' EntityID='$($Component.EntityId)' Instance=$($Component.EntityInstance) Status='$($Component.SignalStatus)' LED='$($Component.IdentifyLED)' CSS='$($Component.CssComponent)'"
$TotalComponentStati++

$DisplayName = $Component.Designation
$SensorType = $Component.SensorType
$EntityIdString = $Component.EntityId
$EntityInstance = $Component.EntityInstance

# Workaround for early instrumentation
if ($EntityInstance -eq '@SENSOR_GET_ENTITY_INSTANCE@') {
$EntityInstance = [string]$i
}

if ($SensorType -eq 'Voltage') {
$VoltageDevicesInfo += "$($VoltageDevices): '$($Component.Designation)'; "
$VoltageDevices++

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.VoltageComponentStatus']$")
# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host host
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusVoltageGroup']/ID$", $voltageComponentGroupDisplayName ) # host

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataType$", $Component.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataId$", $Component.'@odata.id')
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.VoltageStatusGroupHostsVoltageComponentStatus']$")
$relationship.Source = $voltageComponentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} elseif ($SensorType -eq 'Temperature') {
$TemperatureDevicesInfo += "$($TemperatureDevices): '$($Component.Designation)'; "
$TemperatureDevices++

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.TemperatureComponentStatus']$")
# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host host
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusTemperatureGroup']/ID$", $temperatureComponentGroupDisplayName ) # host

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataType$", $Component.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataId$", $Component.'@odata.id')

$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.TemperatureStatusGroupHostsTemperatureComponentStatus']$")
$relationship.Source = $temperatureComponentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} else {
# Evaluate per Entity ID

# Workaround for early instrumentation
if ([String]::IsNullOrEmpty($Component.SensorType)) {
$SensorType = 'reserved'
DebugOut "$IP - Set empty Sensor Type for '$($Component.Designation)' to SensorType='$($SensorType)' SubComponent='$($SubComponent.Value)' EntityID='$($EntityIdString)' Instance=$($EntityInstance) Status='$($Component.SignalStatus)' HealthStatus='$($HealthStatus)'"
} else {
$SensorType = $Component.SensorType
}

DebugOut "$IP -`t'$($Component.Designation)' SensorType='$($SensorType)' EntityID='$($EntityIdString)' Instance=$($EntityInstance) Status='$($Component.SignalStatus)' (old instrumentation)"

if ($EntityIdString -eq "Power Monitoring") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerMonitoringComponentStatus']$")
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsPowerMonitoringComponentStatus']$")
} elseif ($EntityIdString -match "System Firmware") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.BiosComponentStatus']$")
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.BiosComponentStatus']/BiosVersion$", $BiosVersion)
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsBiosComponentStatus']$")
} elseif ($EntityIdString -match "System Management Module") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtCtrlComponentStatus']$")
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsMgmtCtrlComponentStatus']$")
if ($DisplayName -match 'iRMC') {
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtCtrlComponentStatus']/FirmwareVersion$", $BmcFirmwareVersion)
} else {
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtCtrlComponentStatus']/FirmwareVersion$", 'N/A')
}
} else {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatus']$")
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsOtherComponentStatus']$")
}

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host host
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName) # host

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataType$", $Component.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataId$", $Component.'@odata.id')
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

$relationship.Source = $OtherComponentsGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
}
}

# Update HealthCollection Devices/DevicesInfo data
$voltageComponentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$" , "Voltage Component Status: $($VoltageDevices)")
$voltageComponentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", $VoltageDevicesInfo)
$discoveryData.AddInstance($voltageComponentGroupInstance)

# Server hosts Voltage Component Status Group
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsVoltageComponentGroup']$")
$relationship.Source = $serverInstance
$relationship.Target = $voltageComponentGroupInstance
$discoveryData.AddInstance($relationship)

# Additional Mainboard / Voltage Group Relationship
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MainboardReferencesVoltageComponentGroup']$")
$relationship.Source = $mainBoardInstance
$relationship.Target = $voltageComponentGroupInstance
$discoveryData.AddInstance($relationship)

# Update HealthCollection Devices/DevicesInfo data
$temperatureComponentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$" , "Temperature Component Status: $($TemperatureDevices)")
$temperatureComponentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", $TemperatureDevicesInfo)
$discoveryData.AddInstance($temperatureComponentGroupInstance)

# Server hosts Temperature component status group
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsTemperatureComponentGroup']$")
$relationship.Source = $serverInstance
$relationship.Target = $temperatureComponentGroupInstance
$discoveryData.AddInstance($relationship)

# Sub-Group of 'Other'
if ($ComponentRoot.'[email protected]' -gt 0) {
DebugOut "$IP - has $($ComponentRoot.'[email protected]') 'Drive Slot' Component Status Instance(s):"

$componentGroupDisplayName = "Drive Slot Component Status"
$componentGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusDriveSlotGroup']$")
# key(s) of hosting object(s) chain
$componentGroupInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)

$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusDriveSlotGroup']/ID$", $componentGroupDisplayName ) # key
$componentGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $componentGroupDisplayName)
$discoveryData.AddInstance($componentGroupInstance)

# Other Component Group hosts component status sub-group
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsDriveSlotComponentGroup']$")
$relationship.Source = $OtherComponentsGroupInstance
$relationship.Target = $componentGroupInstance
$discoveryData.AddInstance($relationship)

for ($i=0; $i -lt $ComponentRoot.'[email protected]'; $i++) {
$Component = (doWebRequest -url "$hostURL$($ComponentRoot.DriveSlotSensors[$i].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData ) | ConvertFrom-JSON
if ($Component) {
DebugOut "$IP -`t'$($Component.Designation)' SensorType='$($Component.SensorType)' EntityID='$($Component.EntityId)' Instance=$($Component.EntityInstance) Status='$($Component.SignalStatus)' LED='$($Component.IdentifyLED)' CSS='$($Component.CssComponent)'"
$TotalComponentStati++

$DisplayName = $Component.Designation
$EntityIdString = $Component.EntityId
$EntityInstance = $Component.EntityInstance
# Workaround for early instrumentation
if ($EntityInstance -eq '@SENSOR_GET_ENTITY_INSTANCE@') {
$EntityInstance = [string]$i
}
# Workaround for early instrumentation
if ([String]::IsNullOrEmpty($Component.SensorType)) {
$SensorType = 'Drive Slot (Bay)'
} else {
$SensorType = $Component.SensorType
}

if ($Component.SignalStatus -ne "EmptyOrNotInstalled") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.DriveSlotComponentStatus']$")

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusDriveSlotGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataType$", $Component.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataId$", $Component.'@odata.id')
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.DriveSlotStatusGroupHostsDriveSlotComponentStatus']$")
$relationship.Source = $componentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} else {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.DriveSlotNotPresent']$")

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusDriveSlotGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/EntityId$", $EntityIdString) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/EntityInstance$", $EntityInstance) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ServerName$", $ServerName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/Status$", "Empty Slot")
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.DriveSlotStatusGroupHostsDriveSlotNotPresent']$")
$relationship.Source = $componentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
}
}

# Sub-Group of 'Other'
if ($ComponentRoot.'[email protected]' -gt 0) {
DebugOut "$IP - has $($ComponentRoot.'[email protected]') 'PCIe Slot' Component Status Instance(s):"

$componentGroupDisplayName = "PCIe Slot Component Status"
$componentGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPciSlotGroup']$")
# key(s) of hosting object(s) chain
$componentGroupInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)

$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPciSlotGroup']/ID$", $componentGroupDisplayName ) # key
$componentGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $componentGroupDisplayName)
$discoveryData.AddInstance($componentGroupInstance)

# Other Component Group hosts component status sub-group
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsPciSlotComponentGroup']$")
$relationship.Source = $OtherComponentsGroupInstance
$relationship.Target = $componentGroupInstance
$discoveryData.AddInstance($relationship)

for ($i=0; $i -lt $ComponentRoot.'[email protected]'; $i++) {
$Component = (doWebRequest -url "$hostURL$($ComponentRoot.PCISlotSensors[$i].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData ) | ConvertFrom-JSON
if ($Component) {
DebugOut "$IP -`t'$($Component.Designation)' SensorType='$($Component.SensorType)' EntityID='$($Component.EntityId)' Instance=$($Component.EntityInstance) Status='$($Component.SignalStatus)' LED='$($Component.IdentifyLED)' CSS='$($Component.CssComponent)'"
$TotalComponentStati++

$DisplayName = $Component.Designation
$EntityIdString = $Component.EntityId
$EntityInstance = $Component.EntityInstance
# Workaround for early instrumentation
if ($EntityInstance -eq '@SENSOR_GET_ENTITY_INSTANCE@') {
$EntityInstance = [string]$i
}
# Workaround for early instrumentation
if ([String]::IsNullOrEmpty($Component.SensorType)) {
$SensorType = 'Critical Interrupt'
} else {
$SensorType = $Component.SensorType
}

if ($Component.SignalStatus -ne "EmptyOrNotInstalled") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PciSlotComponentStatus']$")

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPciSlotGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataType$", $Component.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataId$", $Component.'@odata.id')
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PciSlotStatusGroupHostsPciSlotComponentStatus']$")
$relationship.Source = $componentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} else {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PciSlotNotPresent']$")

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPciSlotGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/EntityId$", $EntityIdString) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/EntityInstance$", $EntityInstance) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ServerName$", $ServerName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/Status$", "Empty Slot")
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PciSlotStatusGroupHostsPciSlotNotPresent']$")
$relationship.Source = $componentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
}
}

# Sub-Group of 'Other'
if ($ComponentRoot.'[email protected]' -gt 0) {
DebugOut "$IP - has $($ComponentRoot.'[email protected]') 'Power Unit' Component Status Instance(s):"

$componentGroupDisplayName = "Power Unit Components"
$componentGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPowerUnitGroup']$")
# key(s) of hosting object(s) chain
$componentGroupInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)

$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPowerUnitGroup']/ID$", $componentGroupDisplayName ) # key
$componentGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $componentGroupDisplayName)
$discoveryData.AddInstance($componentGroupInstance)

# Other Component Group hosts component sub-group
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsPowerUnitComponentGroup']$")
$relationship.Source = $OtherComponentsGroupInstance
$relationship.Target = $componentGroupInstance
$discoveryData.AddInstance($relationship)

for ($i=0; $i -lt $ComponentRoot.'[email protected]'; $i++) {
$Component = (doWebRequest -url "$hostURL$($ComponentRoot.PowerUnitSensors[$i].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData ) | ConvertFrom-JSON
if ($Component) {
DebugOut "$IP -`t'$($Component.Designation)' SensorType='$($Component.SensorType)' EntityID='$($Component.EntityId)' Instance=$($Component.EntityInstance) Status='$($Component.SignalStatus)' LED='$($Component.IdentifyLED)' CSS='$($Component.CssComponent)'"
$TotalComponentStati++

$DisplayName = $Component.Designation
$EntityIdString = $Component.EntityId
$EntityInstance = $Component.EntityInstance
# Workaround for early instrumentation
if ($EntityInstance -eq '@SENSOR_GET_ENTITY_INSTANCE@') {
$EntityInstance = [string]$i
}
# Workaround for early instrumentation
if ([String]::IsNullOrEmpty($Component.SensorType)) {
$SensorType = 'Power Unit' # typical values are 'Power Unit' and 'Version Change'
} else {
$SensorType = $Component.SensorType
}

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerUnitComponentStatus']$")

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPowerUnitGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataType$", $Component.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataId$", $Component.'@odata.id')
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerUnitStatusGroupHostsPowerUnitComponentStatus']$")
$relationship.Source = $componentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
}

# Sub-Group of 'Other'
if ($ComponentRoot.'[email protected]' -gt 0) {
DebugOut "$IP - has $($ComponentRoot.'[email protected]') 'System Management Software' Component Status Instance(s):"

$componentGroupDisplayName = "Software Component Status"
$componentGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusMgmtSoftwareGroup']$")
# key(s) of hosting object(s) chain
$componentGroupInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)

$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusMgmtSoftwareGroup']/ID$", $componentGroupDisplayName ) # key
$componentGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $componentGroupDisplayName)
$discoveryData.AddInstance($componentGroupInstance)

# Other Component Group hosts component sub-group
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsMgmtSoftwareComponentGroup']$")
$relationship.Source = $OtherComponentsGroupInstance
$relationship.Target = $componentGroupInstance
$discoveryData.AddInstance($relationship)

for ($i=0; $i -lt $ComponentRoot.'[email protected]'; $i++) {
$Component = (doWebRequest -url "$hostURL$($ComponentRoot.SystemManagementSoftwareSensors[$i].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData ) | ConvertFrom-JSON
if ($Component) {
DebugOut "$IP -`t'$($Component.Designation)' SensorType='$($Component.SensorType)' EntityID='$($Component.EntityId)' Instance=$($Component.EntityInstance) Status='$($Component.SignalStatus)' LED='$($Component.IdentifyLED)' CSS='$($Component.CssComponent)'"
$TotalComponentStati++

$DisplayName = $Component.Designation
$EntityIdString = $Component.EntityId
$EntityInstance = $Component.EntityInstance
# Workaround for early instrumentation
if ($EntityInstance -eq '@SENSOR_GET_ENTITY_INSTANCE@') {
$EntityInstance = [string]$i
}
# Workaround for early instrumentation
if ([String]::IsNullOrEmpty($Component.SensorType)) {
$SensorType = 'Management Subsystem Health'
} else {
$SensorType = $Component.SensorType
}

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtSoftwareComponentStatus']$")

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusMgmtSoftwareGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataType$", $Component.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataId$", $Component.'@odata.id')
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtSoftwareStatusGroupHostsMgmtSoftwareComponentStatus']$")
$relationship.Source = $componentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
}

if ($ComponentRoot.'[email protected]' -gt 0) {
DebugOut "$IP - has $($ComponentRoot.'[email protected]') 'System Management Module' Component Status Instance(s):"
for ($i=0; $i -lt $ComponentRoot.'[email protected]'; $i++) {
$Component = (doWebRequest -url "$hostURL$($ComponentRoot.SystemManagementModuleSensors[$i].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData ) | ConvertFrom-JSON
if ($Component) {
DebugOut "$IP -`t'$($Component.Designation)' SensorType='$($Component.SensorType)' EntityID='$($Component.EntityId)' Instance=$($Component.EntityInstance) Status='$($Component.SignalStatus)' LED='$($Component.IdentifyLED)' CSS='$($Component.CssComponent)'"
$TotalComponentStati++

$DisplayName = $Component.Designation
$EntityIdString = $Component.EntityId
$EntityInstance = $Component.EntityInstance
# Workaround for early instrumentation
if ($EntityInstance -eq '@SENSOR_GET_ENTITY_INSTANCE@') {
$EntityInstance = [string]$i
}
# Workaround for early instrumentation
if ([String]::IsNullOrEmpty($Component.SensorType)) {
$SensorType = 'reserved' # typical values are 'reserved'
} else {
$SensorType = $Component.SensorType
}

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtCtrlComponentStatus']$")
if ($DisplayName -match 'iRMC') {
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtCtrlComponentStatus']/FirmwareVersion$", $BmcFirmwareVersion)
} else {
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtCtrlComponentStatus']/FirmwareVersion$", 'N/A')
}

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataType$", $Component.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataId$", $Component.'@odata.id')
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Other Component Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsMgmtCtrlComponentStatus']$")

$relationship.Source = $OtherComponentsGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
}

DebugOut "$IP - Found a total of $($TotalComponentStati) Component Stati up to now..."

$SubComponentTable = [ordered]@{
# 'Processor Sensors' = 'ProcessorSensors';
# 'Memory Sensors' = 'MemorySensors';
# 'Cooling Sensors' = 'CoolingSensors';
# 'PSU Sensors' = 'PSUSensors';

# 'Ambient Sensors' = 'AmbientSensors';
# 'Battery Sensors' = 'BatterySensors';

# 'Power Unit Sensors' = 'PowerUnitSensors';

# 'System Sensors' = 'SystemSensors';
# 'System Management Module Sensors' = 'SystemManagementModuleSensors';
# 'System Management Software Sensors' = 'SystemManagementSoftwareSensors';

# 'PCI Slot Sensors' = 'PCISlotSensors';
# 'Drive Slot Sensors' = 'DriveSlotSensors' ;

# Note: Not in all pre-release firmware versions
'System Firmware Sensors' = 'SystemFirmwareSensors';
'AddIn Card Sensors' = 'AddInCardSensors';
'Misc Sensors' = 'MiscSensors';
}

foreach ($SubComponent in $SubComponentTable.GetEnumerator()) {
if ($ComponentRoot.$($SubComponent.Value).Count -gt 0) {
DebugOut "$IP - has $($ComponentRoot.$($SubComponent.Value).Count) '$($SubComponent.Name)' Component Status Instance(s):"
for ($i=0; $i -lt $ComponentRoot.$($SubComponent.Value).Count; $i++) {
$Component = (doWebRequest -url "$hostURL$($ComponentRoot.$($SubComponent.Value)[$i].'@odata.id')" -Method "GET" -Credentials $NetworkCredential -XAuthData $script:AuthData ) | ConvertFrom-JSON
if ($Component) {
$TotalComponentStati++
if (($Component.SignalStatus -eq 'StatusNotAvailable') -or ($Component.SignalStatus -eq 'EmptyOrNotInstalled') ) {
DebugOut "$IP -`tSkipping '$($Component.Designation)' SensorType='$($Component.SensorType)' EntityID='$($Component.EntityId)' EntityInstance=$($Component.EntityInstance) skipping due to N/A Status='$($Component.SignalStatus)'"
continue
}
DebugOut "$IP - `t'$($Component.Designation)' SensorType='$($Component.SensorType)' EntityID='$($Component.EntityId)' EntityInstance=$($Component.EntityInstance) Status='$($Component.SignalStatus)'"

$DisplayName = $Component.Designation
$EntityIdString = $Component.EntityId
$EntityInstance = $Component.EntityInstance
$SensorType = $Component.SensorType

# Workaround for early instrumentation
if ([String]::IsNullOrEmpty($Component.SensorType)) {
$SensorType = 'reserved'
} else {
$SensorType = $Component.SensorType
}

if ($EntityIdString -eq "Power Monitoring") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerMonitoringComponentStatus']$")
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsPowerMonitoringComponentStatus']$")
} elseif ($EntityIdString -match "System Firmware") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.BiosComponentStatus']$")
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.BiosComponentStatus']/BiosVersion$", $BiosVersion)
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsBiosComponentStatus']$")
} elseif ($EntityIdString -match "System Management Module") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtCtrlComponentStatus']$")
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsMgmtCtrlComponentStatus']$")
if ($DisplayName -match 'iRMC') {
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtCtrlComponentStatus']/FirmwareVersion$", $BmcFirmwareVersion)
} else {
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtCtrlComponentStatus']/FirmwareVersion$", 'N/A')
}
} else {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatus']$")
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsOtherComponentStatus']$")
}

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host host host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # host host
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName) # host

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataType$", $Component.'@odata.type')
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ODataId$", $Component.'@odata.id')
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

$relationship.Source = $OtherComponentsGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

}
}
} else {
DebugOut "$IP - has no '$($SubComponent.Name)' Component Status Instances"
}
}
DebugOut "$IP - Found a total of $($TotalComponentStati) Component Status instances..."
}

# If we get here we are finished
$discoveryData

CloseRedfishSession
DebugOut "$IP - iRMC Discovery (Redfish) - finish"
exit 0


} else {
DebugOut "$IP - Could not get System Root"
}
}
} else {
DebugOut "$IP - No usable Systems information"
}
} else {
DebugOut "$IP - No usable Service Root information"
}

} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Hardware Component Monitoring for Fujitsu Out-Of-Band Server (Redfish): Exception=$_"
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("Hardware Component Monitoring for Fujitsu Out-Of-Band Server (Redfish): Exception=$_")
}

CloseRedfishSession
DebugOut "$IP - Discovery of Fujitsu Out-Of-Band Server (Redfish) - not supported or finished with errors"
}


Function Legacy_Main {

DebugOut "$IP - Discovery of Fujitsu Out-Of-Band Server (Legacy) - start"

# Check if HP-SIM Integration response is delivered from the BMC, we can use this to identify the server type etc.
# and returns 404 when disabled. Used to distinguish Fujitsu iRMC from other vendor WsMan/BMC devices
$Response = DoWebRequest -url ($hostURL + "/xmldata?item=All") -Method "GET" -Credentials $NetworkCredential -RequestTimeout $DEFAULT_REQUEST_TIMEOUT
if ($Response -ne $Null -and $Response.Contains("&lt;RIMP") ) {
try {
$HPSIM_XML = [xml]( Clean-XmlString -xmlString $Response -endTag "&lt;/RIMP&gt;" )
if ($HPSIM_XML -ne $Null -and $HPSIM_XML.HasChildNodes) {
$ServerModel = $($HPSIM_XML.RIMP.HSI.SPN);
$ServerSerialNumber = $($HPSIM_XML.RIMP.HSI.SBSN);
$ServerUuid = $($HPSIM_XML.RIMP.HSI.UUID);
$BmcFirmwareVersion = $($HPSIM_XML.RIMP.MP.FWRI);
$script:HpSimValid = $True
DebugOut "$IP - HP-SIM Integration Response is valid: ServerModel=$ServerModel Serial=$ServerSerialNumber UUID=$ServerUuid Firmware=$BmcFirmwareVersion"
}
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Invalid HP-SIM Integration Response. Exception: $_"
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("Invalid HP-SIM Integration Response. Exception: $_")
}
} else {
DebugOut "$IP - HP-SIM Integration Response not available to identify the Fujitsu Out-Of-Band Server"
}

if ($script:iRMCDetected -eq $False) { # we are not talking to an iRMC - get out
# LogScriptEventWithEventSource -EventSource $IP -EventLevel $INFO_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("is not a supported Fujitsu Out-Of-Band Server")
DebugOut "$IP - is NOT a supported Fujitsu Out-Of-Band Server - giving up"
BailOutAndTestForExisting
}

if ($script:HpSimValid -eq $True) {
if ($ServerModel -match "PRIMEQUEST") {
if ($ServerModel.StartsWith("PRIMEQUEST 3") ) {
DebugOut "$IP - Out-Of-Band Server Discovery: $($ServerModel) $($BmcFirmwareVersion) is supported"
} else {
DebugOut "$IP - Out-Of-Band Server Discovery: $($ServerModel) $($BmcFirmwareVersion) is not supported"
BailOut
}
}

if ( (FirmwareVersionSupported -Version $BmcFirmwareVersion) -eq $False ) {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $INFO_LEVEL -EventNumber $ERROR_UNSUPPORTED_FIRMWARE -Message ("Unsupported Firmware $BmcFirmwareVersion")
DebugOut "$IP - Unsupported Firmware $BmcFirmwareVersion"
BailOut
}
}

# Get the iRMC System Report
try {
# Try to get Component Status information which is not part of the full System Report
# Note: Generating the full report can take some time (especially when RAID data is available) - so use the total timeout value here
$Response = DoWebRequest -url ($hostURL + "/report.xml?Item=System/Components") -Method "GET" -Credentials $NetworkCredential -RequestTimeout $TimeoutSeconds
if ($Response -ne $Null -and $Response.Contains("&lt;Root") ) {
try {
$xml = [xml]( Clean-XmlString -xmlString $Response -endTag "&lt;/Root&gt;" )
if ($xml -ne $Null -and $xml.HasChildNodes ) {
[System.Xml.XmlElement]$compinst = $xml.Root.System.Components

# Check if single items are supported.
# Single items have no Summary section in the generated XML, if it's an old firmware the full report including summary will be generated,
$elem = $xml.Root.Summary

$BmcFirmwareVersion = $xml.Root.GetAttribute("Version")
if ($BmcFirmwareVersion -eq $Null -or $BmcFirmwareVersion -eq "") {
$BmcFirmwareVersion = "N/A"
}
}
} catch {
DebugErr $ERROR_NO_COMPONENT_STATUS_INFORMATION "$IP - Could not process Component Status information. Exception=$_"
BailOutAndTestForExisting
}
} else {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_NO_COMPONENT_STATUS_INFORMATION -Message ("Component Status Information not available")
DebugErr $ERROR_NO_COMPONENT_STATUS_INFORMATION "$IP - Component Status Information not available"
}

if ($elem -ne $Null) {
# We do have a 'Summary' section in the XML which means a partial System Report is not supported.
DebugOut "$IP - Selective System Report requests are NOT supported with Firmware $BmcFirmwareVersion"
$BiosVersion = $xml.Root.System.BIOS.SMBIOS.Type0.BiosVersion
[System.Xml.XmlElement]$cpuinst = $xml.Root.System.Processor
[System.Xml.XmlElement]$meminst = $xml.Root.System.Memory
[System.Xml.XmlElement]$faninst = $xml.Root.System.Fans
[System.Xml.XmlElement]$tempinst = $xml.Root.System.Temperatures
[System.Xml.XmlElement]$voltinst = $xml.Root.System.Voltages
[System.Xml.XmlElement]$psuinst = $xml.Root.System.PowerSupplies
[System.Xml.XmlElement]$fruinst = $xml.Root.System.IDPROMS
} else {
# Single items are supported by the firmware, request them separately one by one (Note: timeout per request can be much shorter)
DebugOut "$IP - Selective System Report requests are supported with Firmware $BmcFirmwareVersion"

# Get overall Status, which contains the server power state
$Response = DoWebRequest -url ($hostURL + "/report.xml?Item=System/Status") -Method "GET" -Credentials $NetworkCredential -RequestTimeout $DEFAULT_REQUEST_TIMEOUT
if ($Response -ne $Null -and $Response.Contains("&lt;Root") ) {
try {
$xml = [xml] ( Clean-XmlString -xmlString $Response -endTag "&lt;/Root&gt;" )
if ($xml -ne $Null -and $xml.HasChildNodes ) {
[bool]$bPowerOn = [bool]($xml.Root.System.Status.PowerState.InnerText -eq 1)
[bool]$bInPost = $False # Assume system is fully running when no information is available
if ($xml.Root.System.Status.PowerState.HasAttribute('PostState')) {
$bInPost = [bool]$xml.Root.System.Status.PowerState.GetAttribute('PostState').ToLower().Equals('true')
}

DebugOut "$IP - Overall Status: '$($xml.Root.System.Status.SystemStatus.Description)' Error_LED: '$($xml.Root.System.Status.ErrorLED.Description)' CSS_LED: '$($xml.Root.System.Status.CssLED.Description)' Identify_LED: '$($xml.Root.System.Status.IdentifyLED.Description)'"
if ($bPowerOn -eq $True) {
DebugOut "$IP - Power is ON; in BIOS/POST: $($bInPost)"
if ($bInPost -eq $True) {
DebugOut "$IP - System is in BIOS/POST/Setup - aborting discovery"
EarlyExit
}
} else {
DebugOut "$IP - Power is OFF - aborting discovery"
EarlyExit
}
}
} catch {
DebugWarn "$IP - Could not process Status information. Exception=$_"
BailOutAndTestForExisting
}
}

$Response = DoWebRequest -url ($hostURL + "/report.xml?Item=System/BIOS") -Method "GET" -Credentials $NetworkCredential -RequestTimeout $DEFAULT_REQUEST_TIMEOUT
if ($Response -ne $Null -and $Response.Contains("&lt;Root") ) {
try {
$xml = [xml] ( Clean-XmlString -xmlString $Response -endTag "&lt;/Root&gt;" )
if ($xml -ne $Null -and $xml.HasChildNodes ) {
$BiosVersion = $xml.Root.System.BIOS.SMBIOS.Type0.BiosVersion
}
} catch {
DebugWarn "$IP - Could not process BIOS information. Exception=$_"
BailOutAndTestForExisting
}
}

$Response = DoWebRequest -url ($hostURL + "/report.xml?Item=System/Processor") -Method "GET" -Credentials $NetworkCredential -RequestTimeout $DEFAULT_REQUEST_TIMEOUT
if ($Response -ne $Null -and $Response.Contains("&lt;Root") ) {
try {
$xml = [xml] ( Clean-XmlString -xmlString $Response -endTag "&lt;/Root&gt;" )
if ($xml -ne $Null -and $xml.HasChildNodes ) {
[System.Xml.XmlElement]$cpuinst = $xml.Root.System.Processor
}
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Could not process Processor information. Exception=$_"
BailOutAndTestForExisting
}
} else {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_NO_PROCESSOR_INFORMATION -Message ("Processor Information not available")
DebugErr $ERROR_NO_PROCESSOR_INFORMATION "$IP - Processor Information not available"
BailOutAndTestForExisting
}

# Note: Allow more time for the maximum of 128 Memory Modules (reading the 512 Byte SPD Data takes some time)
$Response = DoWebRequest -url ($hostURL + "/report.xml?Item=System/Memory") -Method "GET" -Credentials $NetworkCredential -RequestTimeout (2*$DEFAULT_REQUEST_TIMEOUT)
if ($Response -ne $Null -and $Response.Contains("&lt;Root") ) {
try {
$xml = [xml] ( Clean-XmlString -xmlString $Response -endTag "&lt;/Root&gt;" )
if ($xml -ne $Null -and $xml.HasChildNodes ) {
[System.Xml.XmlElement]$meminst = $xml.Root.System.Memory
}
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Could not process Memory information. Exception=$_"
BailOutAndTestForExisting
}
} else {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_NO_MEMORY_INFORMATION -Message ("Memory Information not available")
DebugErr $ERROR_NO_MEMORY_INFORMATION "$IP - Memory Information not available"
BailOutAndTestForExisting
}

$Response = DoWebRequest -url ($hostURL + "/report.xml?Item=System/Fans") -Method "GET" -Credentials $NetworkCredential -RequestTimeout $DEFAULT_REQUEST_TIMEOUT
if ($Response -ne $Null -and $Response.Contains("&lt;Root") ) {
try {
$xml = [xml] ( Clean-XmlString -xmlString $Response -endTag "&lt;/Root&gt;" )
if ($xml -ne $Null -and $xml.HasChildNodes ) {
[System.Xml.XmlElement]$faninst = $xml.Root.System.Fans
}
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Could not process Fan information. Exception=$_"
BailOutAndTestForExisting
}
} else {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_NO_FAN_INFORMATION -Message ("Fan Information not available")
DebugErr $ERROR_NO_FAN_INFORMATION "$IP - Fan Information not available"
BailOutAndTestForExisting
}

$Response = DoWebRequest -url ($hostURL + "/report.xml?Item=System/PowerSupplies") -Method "GET" -Credentials $NetworkCredential -RequestTimeout $DEFAULT_REQUEST_TIMEOUT
if ($Response -ne $Null -and $Response.Contains("&lt;Root") ) {
try {
$xml = [xml] ( Clean-XmlString -xmlString $Response -endTag "&lt;/Root&gt;" )
if ($xml -ne $Null -and $xml.HasChildNodes ) {
[System.Xml.XmlElement]$psuinst = $xml.Root.System.PowerSupplies
}
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Could not process Power Supply information. Exception=$_"
BailOutAndTestForExisting
}
} else {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_NO_POWER_SUPPLY_INFORMATION -Message ("Power Supply Information not available")
DebugErr $ERROR_NO_POWER_SUPPLY_INFORMATION "$IP - Power Supply Information not available"
BailOutAndTestForExisting
}

$Response = DoWebRequest -url ($hostURL + "/report.xml?Item=System/IDPROMS") -Method "GET" -Credentials $NetworkCredential -RequestTimeout $DEFAULT_REQUEST_TIMEOUT
if ($Response -ne $Null -and $Response.Contains("&lt;Root") ) {
try {
$xml = [xml] ( Clean-XmlString -xmlString $Response -endTag "&lt;/Root&gt;" )
if ($xml -ne $Null -and $xml.HasChildNodes ) {
[System.Xml.XmlElement]$fruinst = $xml.Root.System.IDPROMS
}
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Could not process IDPROM information. Exception=$_"
BailOutAndTestForExisting
}
}

}
} catch {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("Fujitsu Out-Of-Band Server Discovery: Could not read System Report Exception=$_")
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Fujitsu Out-Of-Band Server Discovery: Could not read System Report Exception=$_"
EarlyExit
}

# Test (again) for supported firmware version based on system report response in case HP-SIM was disabled
if ($BmcFirmwareVersion -ne "N/A") {
if ( (FirmwareVersionSupported -Version $BmcFirmwareVersion ) -eq $True ) {
DebugOut "$IP - Firmware $BmcFirmwareVersion is supported"
} else {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $INFO_LEVEL -EventNumber $ERROR_UNSUPPORTED_FIRMWARE -Message ("Unsupported Firmware $BmcFirmwareVersion")
DebugOut "$IP - Unsupported Firmware $BmcFirmwareVersion - giving up"
BailOut
}
} else {
DebugOut "$IP - Could not determine Firmware Version - giving up"
BailOutAndTestForExisting
}

#############################################################################################
$NetworkName = $IP # default is plain IP until otherwise proven

# Get the iRMC Configuration
# Note: For historical reasons the 'Configure iRMC Settings' extended permission is required.
try {
$Response = DoWebRequest -url ($hostURL + "/iRMC_Settings.pre?SAVE_ALL=1") -Method "GET" -Credentials $NetworkCredential -RequestTimeout $DEFAULT_REQUEST_TIMEOUT -IgnoreNoPermission
if ($Response -ne $Null -and $Response.Contains("&lt;CMDSEQ") ) {
try {
$xml = [xml]( Clean-XmlString -xmlString $Response -endTag "&lt;/CMDSEQ&gt;" )
if ($xml -ne $Null -and $xml.HasChildNodes ) {

# ConfServerOperatingSystem
$a = $xml.CMDSEQ.CMD | where { $_.OE -eq '20F' -and $_.OI -eq '0'}
if (($a.STATUS -eq '0') -and ($a.DATA.Type -eq "xsd::string") -and ($a.DATA.InnerText -ne "") ){
DebugOut "$IP - Server Operating System '$($a.DATA.InnerText)'"
$ServerOperatingSystem = $a.DATA.InnerText
} else {
DebugOut "$IP - Server Operating System NOT configured (empty)!"
}
# ConfBMCAssetTag
$a = $xml.CMDSEQ.CMD | where { $_.OE -eq '210' -and $_.OI -eq '0'}
if (($a.STATUS -eq '0') -and ($a.DATA.Type -eq "xsd::string") -and ($a.DATA.InnerText -ne "") ){
DebugOut "$IP - Asset Tag '$($a.DATA.InnerText)'"
$ServerAssetTag = $a.DATA.InnerText
} else {
DebugOut "$IP - Asset Tag NOT configured (empty)!"
}

# ConfBMCDNSDomain
$a = $xml.CMDSEQ.CMD | where { $_.OE -eq '144D' -and $_.OI -eq '0'}
if (($a.STATUS -eq '0') -and ($a.DATA.Type -eq "xsd::string") -and ($a.DATA.InnerText -ne "") ){
DebugOut "$IP - DNS Domain '$($a.DATA.InnerText)'"
$ServerDnsDomain = $a.DATA.InnerText
} else {
DebugOut "$IP - DNS Domain NOT configured (empty)!"
}

# ConfBmcDnsNameString
$a = $xml.CMDSEQ.CMD | where { $_.OE -eq '2550' -and $_.OI -eq '0'}
if (($a.STATUS -eq '0') -and ($a.DATA.Type -eq 'xsd::string') -and ($a.DATA.InnerText -ne "") ) {
DebugOut "$IP - DNS Name '$($a.DATA.InnerText)'"
$ServerDnsName = $a.DATA.InnerText
} else {
DebugOut "$IP - DNS name NOT reported - building from scratch ..."
[bool]$DnsNameInvalid = $False

# ConfBMCUseNetworkName
$a = $xml.CMDSEQ.CMD | where { $_.OE -eq '1431' -and $_.OI -eq '0'}
if (($a.STATUS -eq '0') -and ($a.DATA.Type -eq 'xsd::integer')) {
if ($a.DATA.InnerText -eq '1') {
DebugOut "$IP - DNS Use BMC Name ..."
# ConfBMCNetworkName
$a = $xml.CMDSEQ.CMD | where { $_.OE -eq '1430' -and $_.OI -eq '0'}
if (($a.STATUS -eq '0') -and ($a.DATA.Type -eq 'xsd::string') -and ($a.DATA.InnerText -ne "")) {
$ServerDnsName = $($a.DATA.InnerText)
}
} else {
# ConfSystemName
$a = $xml.CMDSEQ.CMD | where { $_.OE -eq '201' -and $_.OI -eq '0'}
if (($a.STATUS -eq '0') -and ($a.DATA.Type -eq 'xsd::string') -and ($a.DATA.InnerText -ne "") -and ($a.DATA.InnerText -ne "- unknown -")) {
$HostName = $($a.DATA.InnerText)
if ($HostName.contains( '.' )) {
$ServerDnsName = $HostName.Substring( 0, ($HostName.IndexOf('.')))
} else {
$ServerDnsName = $HostName
}
} else {
DebugOut "$IP - DNS System Name empty or non unique default '$($a.DATA.InnerText)'..."
$DnsNameInvalid = $True
}
}
} else {
if (($a.STATUS -ne '0') -and ($a.ERROR -ne $Null) ){
DebugOut "$IP - Building DNS Name: $($a.ERROR)!"
}
$DnsNameInvalid = $True
}

# ConfBMCAddSerialNumber
$a = $xml.CMDSEQ.CMD | where { $_.OE -eq '1433' -and $_.OI -eq '0'}
if (($a.STATUS -eq '0') -and ($a.DATA.Type -eq 'xsd::integer')) {
if ($a.DATA.InnerText -eq '1') {
DebugOut "$IP - DNS Add Serial ..."

# We need to get the MAC Address of the iRMC, last 3 Bytes are used as serial
$Response = DoWebRequest -url ($hostURL + "/report.xml?Item=System/ManagementControllers") -Method "GET" -Credentials $NetworkCredential -RequestTimeout $TimeoutSeconds
if ($Response -ne $Null -and $Response.Contains("&lt;Root") ) {
try {
$xmlCtrl = [xml]( Clean-XmlString -xmlString $Response -endTag "&lt;/Root&gt;" )
if ($xmlCtrl -ne $Null -and $xmlCtrl.HasChildNodes ) {
[System.Xml.XmlElement]$bmcinst = $xmlCtrl.Root.System.ManagementControllers.iRMC
[string]$MacAddress = $bmcInst.MACAddress
$ServerDnsName += ($MacAddress.Replace('-','')).SubString(6)
}
} catch {
DebugErr $ERROR_NO_CONFIG_INFORMATION "$IP - Could not process Management Controller Information. Exception=$_"
$DnsNameInvalid = $True
}
} else {
DebugWarn "$IP - Management Controller Information not available for MAC address based serial"
$DnsNameInvalid = $True
}
}
} else {
$DnsNameInvalid = $True
}

# ConfBMCAddExtension
$a = $xml.CMDSEQ.CMD | where { $_.OE -eq '1434' -and $_.OI -eq '0'}
if (($a.STATUS -eq '0') -and ($a.DATA.Type -eq 'xsd::integer')) {
if ($a.DATA.InnerText -eq '1') {
DebugOut "$IP - DNS Add Extension ..."
# ConfBMCNameExtension
$a = $xml.CMDSEQ.CMD | where { $_.OE -eq '1432' -and $_.OI -eq '0'}
if (($a.DATA.Type -eq "xsd::string") -and ($a.DATA.InnerText -ne "") ){
DebugOut "$IP - DNS Name Extension $($a.DATA.InnerText)"
$ServerDnsName += $($a.DATA.InnerText)
}
}
} else {
$DnsNameInvalid = $True
}

if ($ServerDnsName.contains( ' ' )) {
$ServerDnsName = $ServerDnsName.Replace(' ','-')
}

DebugOut "$IP - Final DNS Name: '$($ServerDnsName)'"
}

DebugOut "$IP - DnsNameInvalid=$($DnsNameInvalid) ServerDnsName='$($ServerDnsName)' ServerDnsDomain='$($ServerDnsDomain)'"

if ( ($DnsNameInvalid -eq $False) -and ($ServerDnsName -ne 'N/A') -and ($ServerDnsName -ne 'iRMC') -and ($ServerDnsName -ne '- unknown -')) {
if ($ServerDnsDomain -ne 'N/A') {
$DnsName = $ServerDnsName +"." +$ServerDnsDomain
} else {
$DnsName = $ServerDnsName
}
} else {
$DnsName = $IP
}
}

} catch {
DebugErr $ERROR_NO_CONFIG_INFORMATION "$IP - Could not process iRMC Configuration information."
BailOutAndTestForExisting
}
} else {
if ($script:httpStatusCode -eq [System.Net.HttpStatusCode]::Forbidden) {
DebugOut "$IP - iRMC Configuration Information not available (no permission)"
} else {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_NO_CONFIG_INFORMATION -Message ("iRMC Configuration Information not available")
DebugErr $ERROR_NO_CONFIG_INFORMATION "$IP - iRMC Configuration Information not available"
BailOutAndTestForExisting
}
}
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - iRMC Configuration Discovery: Exception=$_"
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("Fujitsu Out-Of-Band Configuration Discovery: Exception=$_ ")
BailOutAndTestForExisting
}

&lt;# Typical IDPROM content
Product Information
0600 Product Serial Number YLVT000098
0601 Product Part Number ABN:K1495-VXXX-XX
0608 Product Model PRIMERGY RX2540 M1
060A Product Manufacturer FUJITSU
060B Product Manufacturing Date 2014/07/16 17:31:00
060C Product File ID 0
Chassis Information
0100 Chassis Serial Number bbbbbbbb
0101 Chassis Part Number 340C24800011
0108 Chassis Model TX140S2FZ
System Board Information
0200 System Board Serial Number 45283645
0201 System Board Part Number S26361-D3279-D11
0203 System Board Version WGS02 GS50
0208 System Board Model D3279
020A System Board Manufacturer FUJITSU
020B System Board Manufacturing Date 2014/08/08 03:43:00
#&gt;
try {
# Product (SCCI Class 6) Information from FRU/IDPROM
[bool]$bHasProductInfo = $False # Older BX or CX systems report 2 Mainboard FRU instead

$a = $fruinst.Class | where { $_.Code -eq "6" }
if ($a -ne $Null) {
$bHasProductInfo = $True
DebugOut "$IP - $($a.GetAttribute('Name')) FRU Information"
$b = @($a.Instance.Data.Decoded.String)
for($i = 0; $i -lt $b.Count; $i++){
DebugOut "$IP -`t$($b[$i].ValueID) $($b[$i].ValueName) $($b[$i].InnerText)"

if ($b[$i].ValueID -eq "0600") { $ServerSerialNumber = $b[$i].InnerText}
if ($b[$i].ValueID -eq "0601") { $ServerPartNumber = $b[$i].InnerText}
if ($b[$i].ValueID -eq "0608") { $ServerModel = $b[$i].InnerText}
if ($b[$i].ValueID -eq "0609") { $ServerManufacturer = $b[$i].InnerText} # Older Firmware 7.50F (Vendor vs. Manufacturer)
if ($b[$i].ValueID -eq "060A") { $ServerManufacturer = $b[$i].InnerText}
if ($b[$i].ValueID -eq "060B") { $ServerManufacturingDate = $b[$i].InnerText}
}
}

# Chassis (SCCI Class 1) Information from FRU/IDPROM
$a = $fruinst.Class | where { $_.Code -eq "1" }
if ($a -ne $Null) {
DebugOut "$IP - $($a.GetAttribute('Name')) FRU Information"
$b = @($a.Instance.Data.Decoded.String)
for($i = 0; $i -lt $b.Count; $i++){
DebugOut "$IP -`t$($b[$i].ValueID) $($b[$i].ValueName) $($b[$i].InnerText)"

if ($b[$i].ValueID -eq "0100") { $ChassisSerialNumber = $b[$i].InnerText}
if ($b[$i].ValueID -eq "0101") { $ChassisPartNumber = $b[$i].InnerText}
if ($b[$i].ValueID -eq "0108") { $ChassisModel = $b[$i].InnerText}
}
}

# Extract System board (SCCI Class 2) Information from FRU/IDPROM
$a = $fruinst.Class | where { $_.Code -eq "2" }
if ($a -ne $Null) {
$b = @($a.Instance.Data.Decoded.String)

DebugOut "$IP - $($a.GetAttribute('Name')) FRU Information"
for($i = 0; $i -lt $b.Count; $i++){
DebugOut "$IP -`t$($b[$i].ValueID) $($b[$i].ValueName) $($b[$i].InnerText)"
}

$c_200 = @($b | where { $_.ValueId -eq "0200"}) # Serial Number
$c_201 = @($b | where { $_.ValueId -eq "0201"}) # Part Number
$c_203 = @($b | where { $_.ValueId -eq "0203"}) # Version
$c_208 = @($b | where { $_.ValueId -eq "0208"}) # Model
$c_209 = @($b | where { $_.ValueId -eq "0209"}) # Vendor (Manufacturer) in old Firmware version e.g. 7.50F
$c_20A = @($b | where { $_.ValueId -eq "020A"}) # Manufacturer
$c_20B = @($b | where { $_.ValueId -eq "020B"}) # Manufacturing Date
$c_20C = @($b | where { $_.ValueId -eq "020C"}) # File ID
# Note: Due to a bug, Blades (BX) and Multi Node Systems (CX) deliver Product and Mainboard information in one FRU section
if (!$bHasProductInfo -and $c_200.Count -eq 2) {
$ServerSerialNumber = $c_200[0].InnerText
$BoardSerialNumber = $c_200[1].InnerText
} else {
$BoardSerialNumber = $c_200[0].InnerText
}
if (!$bHasProductInfo -and $c_201.Count -eq 2) {
$ServerPartNumber = $c_201[0].InnerText
$BoardPartNumber = $c_201[1].InnerText
} else {
$BoardPartNumber = $c_201[0].InnerText
}
if (!$bHasProductInfo -and $c_203.Count -eq 2) {
$ServerVersion = $c_203[0].InnerText
$BoardVersion = $c_203[1].InnerText
} else {
$BoardVersion = $c_203[0].InnerText
}
if (!$bHasProductInfo -and $c_208.Count -eq 2) {
$ServerModel = $c_208[0].InnerText
$BoardModel = $c_208[1].InnerText
} else {
$BoardModel = $c_208[0].InnerText
}
if (!$bHasProductInfo -and $c_209.Count -eq 2) { # Old Firmware Vendor instead of Manufacturer
$ServerManufacturer = $c_209[0].InnerText
$BoardManufacturer = $c_209[1].InnerText
} else {
$BoardManufacturer = $c_209[0].InnerText
}
if (!$bHasProductInfo -and $c_20A.Count -eq 2) {
$ServerManufacturer = $c_20A[0].InnerText
$BoardManufacturer = $c_20A[1].InnerText
} else {
$BoardManufacturer = $c_20A[0].InnerText
}
if (!$bHasProductInfo -and $c_20B.Count -eq 2) {
$ServerManufacturingDate = $c_20B[0].InnerText
$BoardManufacturingDate = $c_20B[1].InnerText
} else {
$BoardManufacturingDate = $c_20B[0].InnerText
}
}

# Power Supply (SCCI Class 8) Information from FRU/IDPROM
$a = $fruinst.Class | where { $_.Code -eq "8" }
if ($a -ne $Null -and $a.HasChildNodes) {
$b = @( $a.Instance )
for ($j=0; $j -lt $b.Count; $j++) {
if ($b -ne $Null -and $b.HasChildNodes) {
DebugOut "$IP - $($b[$j].GetAttribute('ClassName')) FRU Information Index: $($b[$j].GetAttribute('Index'))"
$c = $b[$j].Data.Decoded.String
for($i = 0; $i -lt $c.Count; $i++){
DebugOut "$IP -`t$($c[$i].ValueID) $($c[$i].ValueName) $($c[$i].InnerText)"
}
}
}
}

} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - FRU/IDPROM Discovery: Exception=$_"
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("Fujitsu Out-Of-Band Server IDPROM Discovery: Exception=$_ ")
}

#############################################################################################

# We have all information we need, create discovered Instances
$bmcInstance = $discoveryData.CreateClassInstance("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']$")
$bmcInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # key
# $bmcInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $IP)
$discoveryData.AddInstance($bmcInstance)

if ($ServerModel -ne "N/A") {
if ($ServerModel -match "PRIMERGY BX" ) {
$serverInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.BXServer']$")
} elseif ($ServerModel -match "PRIMERGY CX" ) {
$serverInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.CXServer']$")
} elseif ($ServerModel -match "PRIMERGY RX" ) {
$serverInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.RXServer']$")
} elseif ($ServerModel -match "PRIMERGY SX" ) {
$serverInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.SXServer']$")
} elseif ($ServerModel -match "PRIMERGY TX" ) {
$serverInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.TXServer']$")
} else { # Any other: use generic XX Type
$serverInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.XXServer']$")
}
} else {
DebugOut "$IP - Could not determine Server Model!"
$serverInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.XXServer']$")
}

$serverInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host

if ($UseDnsNameAsNetworkName -eq $True) {
$NetworkName = $DnsName
$serverInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $DnsName) # key
} else {
$serverInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $IP) # key
}
if ($UseDnsNameAsDisplayName -eq $True) {
$ServerName = $DnsName
} else {
$ServerName = $IP
}
$serverInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.System']/Model$", $ServerModel)
$serverInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.System']/SerialNumber$", $ServerSerialNumber)
$serverInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.System']/OperatingSystem$", $ServerOperatingSystem)
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/ManagementUrl$", $hostURL)
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/BmcFirmware$", $BmcFirmwareVersion)
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/Manufacturer$", $ServerManufacturer)
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/ManufacturingDate$", $ServerManufacturingDate)
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/PartNumber$", $ServerPartNumber)
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/ChassisModel$", $ChassisModel)
if ($BiosVersion -ne $Null -and $BiosVersion -ne "") {
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/SystemFirmware$", $BiosVersion)
}

$physicalMemory = 'N/A'
if ($meminst -ne $Null -and $meminst.HasChildNodes) {
if ($meminst.Installed -ne $Null -and $meminst.Installed -ne 0) {
# We do have a valid total, so the modules will have information as well
DebugOut "$IP - Total installed memory is $($meminst.Installed)"
try {
[int]$totalMemory = $meminst.Installed # in MB
[string]$physicalMemory = ''
if ($totalMemory -lt 1024) {
$physicalMemory = "$($totalMemory) MB"
} else {
if (($totalMemory % 1024) -eq 0) {
$physicalMemory = "{0:d} GB" -f ($totalMemory/1024)
} else {
$physicalMemory = "{0:f} GB" -f ($totalMemory/1024)
}
}
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/PhysicalMemory$", $physicalMemory) # actual value
DebugOut "$IP - Physical Memory: $($physicalMemory)"

} catch {}
}
}

$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/PhysicalMemory$", $physicalMemory)
$serverInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Server']/DnsName$", $DnsName)
$serverInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $ServerName)
$discoveryData.AddInstance($serverInstance)

# BMC hosts Out-Of-Band Server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.iRMCDeviceHostsServer']$")
$relationship.Source = $bmcInstance
$relationship.Target = $serverInstance
$discoveryData.AddInstance($relationship)

# Communication Monitor
$commName = 'Communication Monitor'
$commInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.CommunicationMonitor']$")
# key(s) of hosting chain object(s)
$commInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$commInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$commInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.CommunicationMonitor']/ID$", $commName)
$commInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $commName)
$discoveryData.AddInstance($commInstance)

# Communication Component hosted by Server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsCommunicationMonitor']$")
$relationship.Source = $serverInstance
$relationship.Target = $commInstance
$discoveryData.AddInstance($relationship)

try {
if ($BoardModel -ne "N/A") {
$DisplayName = $MainboardName
$mainBoardInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard']$")

# key(s) of hosting chain object(s)
$mainBoardInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$mainBoardInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)

$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ID$", $DisplayName) # key
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ManagementUrl$", $hostURL)
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ServerName$", $ServerName)

$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard']/Model$" , $BoardModel)
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard']/Manufacturer$" , $BoardManufacturer)
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard']/ManufacturingDate$", $BoardManufacturingDate)
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard']/PartNumber$" , $BoardPartNumber)
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard']/SerialNumber$" , $BoardSerialNumber)
$mainBoardInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Mainboard']/Version$" , $BoardVersion)
$mainBoardInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($mainBoardInstance)

# Mainboard hosted by server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsMainboard']$")
$relationship.Source = $serverInstance
$relationship.Target = $mainBoardInstance
$discoveryData.AddInstance($relationship)
}
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Mainboard Discovery: Exception=$_"
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("Fujitsu Out-Of-Band Server Mainboard Discovery: Exception=$_ ")
}

try {
if ($cpuinst -ne $Null -and $cpuinst.HasChildNodes) {
# Processor Group
$groupName = $ProcessorGroupName
$cpuGroupInst = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ProcessorGroup']$")
$cpuGroupInst.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$cpuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # key of hosting object

# HealthCollection Class Properties: Get List of devices
$Devices = "N/A"
$DevicesInfo = ""
$index = 0
foreach ($elem in $cpuinst.CPU) {
$DisplayName = $elem.SocketDesignation
$Status = $elem.Status.GetAttribute("Description")

#$Devices += "$($index): '$($DisplayName)'; "
if ($Status -ne "empty") {
$Model = 'N/A'
$NumLogicalCores = 'N/A'
$NumPhysicalCores = 'N/A'
if ($elem.LogicalCpuNumber -ne $Null) { $NumLogicalCores = $elem.LogicalCpuNumber}
if ($elem.CoreNumber -ne $Null) { $NumPhysicalCores = $elem.CoreNumber}
if ($elem.Model.Version -ne $Null) { $Model = $elem.Model.Version}

if ($Model -ne 'N/A' -and $NumPhysicalCores -ne 'N/A' -and $NumLogicalCores -ne 'N/A' ) {
$DevicesInfo += "$($index): '$($DisplayName)' '$($Model)' Phys. Cores: $($NumPhysicalCores), Log. Threads: $($NumLogicalCores); "
} else {
$DevicesInfo += "$($index): '$($DisplayName)'; "
}
} else {
if ($IncludeNotPresentProcessors -eq $True) {
$DevicesInfo += "$($index): '$($DisplayName)' (Empty socket); "
}
}
$index++
}
if ($index -ne 0) {
$Devices = "Processors: $($index)"
}

$cpuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$" , $IP)
$cpuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$" , $Devices)
$cpuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", $DevicesInfo)

$cpuGroupInst.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)
$cpuGroupInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $groupName)
$discoveryData.AddInstance($cpuGroupInst)

# Processor Group hosted by Server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsProcessorGroup']$")
$relationship.Source = $serverInstance
$relationship.Target = $cpuGroupInst
$discoveryData.AddInstance($relationship)

foreach ($elem in $cpuinst.CPU) {
$DisplayName = $elem.SocketDesignation
$Status = $elem.Status.GetAttribute("Description")
if ($Status -ne "empty") {
DebugOut "$IP - Processor '$DisplayName' Model: '$($elem.Model.Version)' Vendor: '$($elem.Manufacturer)' Speed: $($elem.Speed) Logical Cores: $($elem.LogicalCpuNumber) Status: '$Status'"

# Default to 'N/A' in case the iRMC has lost this information and needs a server reboot/POST
$Model = 'N/A'
$Manufacturer = 'N/A'
$NumLogicalCores = 'N/A'
$NumPhysicalCores = 'N/A'
$MaxClockSpeed = 'N/A'

$L1Cache = 'N/A'
$L2Cache = 'N/A'
$L3Cache = 'N/A'

if ($elem.Model.Version -ne $Null) { $Model = $elem.Model.Version}
if ($elem.Manufacturer -ne $Null) { $Manufacturer = $elem.Manufacturer}
if ($elem.LogicalCpuNumber -ne $Null) { $NumLogicalCores = $elem.LogicalCpuNumber}
if ($elem.CoreNumber -ne $Null) { $NumPhysicalCores = $elem.CoreNumber}
if ($elem.Speed -ne $Null) { $MaxClockSpeed = $elem.Speed}

if ($elem.Level1CacheSize.InnerText -ne $Null) { $L1Cache = $elem.Level1CacheSize.InnerText +" " +$elem.Level1CacheSize.GetAttribute("Unit") }
if ($elem.Level2CacheSize.InnerText -ne $Null) { $L2Cache = $elem.Level2CacheSize.InnerText +" " +$elem.Level2CacheSize.GetAttribute("Unit") }
if ($elem.Level3CacheSize.InnerText -ne $Null) { $L3Cache = $elem.Level3CacheSize.InnerText +" " +$elem.Level3CacheSize.GetAttribute("Unit") }

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']$")

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ServerName$", $ServerName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/Model$" , $Model)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/Manufacturer$" , $Manufacturer)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/NumLogicalCores$" , $NumLogicalCores)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/NumPhysicalCores$", $NumPhysicalCores)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/MaxClockSpeed$" , $MaxClockSpeed)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/L1Cache$" , $L1Cache)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/L2Cache$" , $L2Cache)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Processor']/L3Cache$" , $L3Cache)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)

$discoveryData.AddInstance($instance)

# Processor Group hosted by Server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ProcessorGroupHostsProcessor']$")
$relationship.Source = $cpuGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} else {
DebugOut "$IP - Processor '$DisplayName' Status: '$Status'"
if ($IncludeNotPresentProcessors -eq $True) {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ProcessorNotPresent']$")

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent']/Status$", "CPU not installed")
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $elem.SocketDesignation)
$discoveryData.AddInstance($instance)

# Group hosts Non Present component
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ProcessorGroupHostsProcessorNotPresent']$")
$relationship.Source = $cpuGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
}
} else {
# Every Server has at least one active CPU or it won't boot.
# Mark Discovery as incomplete if we don't have any CPU information
BailOutAndTestForExisting
}
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Processor Discovery: Exception=$_"
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("Fujitsu Out-Of-Band Server Processor Discovery: Exception=$_ ")
BailOutAndTestForExisting
}

try {
# Memory
if ($meminst -ne $Null -and $meminst.HasChildNodes) {

# HealthCollection Class Properties: Get List of devices
# try to match other MP's Device and Device Info
$Devices = "N/A"
$DevicesInfo = ""

if ($meminst.Installed -ne $Null -and $meminst.Installed -ne 0){
# We do have a valid total, so the modules will have information as well
DebugOut "$IP - Total installed memory is $($meminst.Installed)"
try {
[int]$totalMemory = $meminst.Installed # in MB
if ($totalMemory -lt 1024) {
$DevicesInfo = "Overall Memory: $($totalMemory) MB; "
} else {
if (($totalMemory % 1024) -eq 0) {
$DevicesInfo = "Overall Memory: {0:d} GB; " -f ($totalMemory/1024)
} else {
$DevicesInfo = "Overall Memory: {0:f} GB; " -f ($totalMemory/1024)
}
}
} catch {}

# Build Device Info (list and count of size XX memory modules)
$index = 0
$mem_types = @{}
foreach ($elem in $meminst.Modules.Module) {
$DisplayName = $elem.Name
$Status = $elem.Status.GetAttribute("Description")
if ($Status -ne "empty" -and $Status -ne "hidden") {
if ($elem.ConfigStatus -ne $Null) {
$ConfigStatus= $elem.ConfigStatus.GetAttribute("Description")
} else {
$ConfigStatus = 'N/A'
}

if ($ConfigStatus -ne 'Not usable') {
if (($elem.Size.InnerText -ne $Null) -and ($elem.Size.Unit -ne $Null)) { # Old Version with Unit attribute
$MemSize = $elem.Size.InnerText +" " +$elem.Size.Unit
} else {
[int]$size = [int]$elem.Size
if ($size -lt 1024) {
$MemSize = [string]$elem.Size +" MB"
} else {
$MemSize = [string]($size/1024) +" GB"
}
}
} else {
$MemSize = $ConfigStatus # also count/list 'Not usable' modules
}

if ($mem_types.ContainsKey($MemSize)) {
$count = $mem_types.Get_Item($MemSize) + 1
$mem_types.Set_Item($MemSize, $count)
} else {
$mem_types.Add($MemSize, 1)
}
$index++
}
}

if ($index -ne 0) {
$Devices = "Memory Modules: $($index)"
$DevicesInfo += "Memory Types: "
foreach ($key in $mem_types.Keys) {
$DevicesInfo += "'$($key)': $($mem_types[$key]), "
}
}

} else {
# Memory information incomplete, list devices
DebugOut "$IP - installed memory information not available"
$Devices = ""
$DevicesInfo = ""
$index = 0
foreach ($elem in $meminst.Modules.Module) {
$DisplayName = $elem.Name
$Status = $elem.Status.GetAttribute("Description")
if ($Status -ne "empty" -and $Status -ne "hidden") {
$DevicesInfo += "$($index): '$($DisplayName)'; "
$index++
}
}
if ($index -ne 0) {
$Devices = "Memory Modules: $($index)"
} else {
$Devices = "N/A"
$DevicesInfo = "N/A"
}
}

# Memory Group
$groupName = $MemoryGroupName
$memGroupInst = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryGroup']$")
$memGroupInst.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$memGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # key of hosting object

$memGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$" , $IP)
$memGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$" , $Devices)
$memGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", $DevicesInfo)

$memGroupInst.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)
$memGroupInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $groupName)
$discoveryData.AddInstance($memGroupInst)

# Memory Group hosted by Server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsMemoryGroup']$")
$relationship.Source = $serverInstance
$relationship.Target = $memGroupInst
$discoveryData.AddInstance($relationship)

$index = 0
foreach ($elem in $meminst.Modules.Module) {
$DisplayName = $elem.Name
$Status = $elem.Status.GetAttribute("Description")
DebugOut "$IP - Memory Module '$($DisplayName)' Status: '$($Status)'"

if ($Status -ne "empty" -and $Status -ne "hidden") {
if ($elem.ConfigStatus -ne $Null) {
$ConfigStatus= $elem.ConfigStatus.GetAttribute("Description")
} else {
$ConfigStatus = 'N/A'
}

if ($ConfigStatus -ne 'Not usable') {
if ($elem.BusFrequency -ne $Null) {
$BusFrequency = [string]($elem.BusFrequency.InnerText +" " +$elem.BusFrequency.Unit)
}
if (($elem.Size -ne $Null) -and ($elem.Size.Unit -ne $Null)) {
# Old Firmware Version with Unit attribute
$MemSize = $elem.Size.InnerText +" " +$elem.Size.Unit
} else {
[int]$size = [int]$elem.Size
if ($size -lt 1024) {
$MemSize = [string]$elem.Size +" MByte"
} else {
$MemSize = [string]($size/1024) +" GByte"
}
}
if ( ($elem.Type-ne $Null) -and ($elem.SPD.ModuleType -ne $Null) ) {
$MemType = $elem.Type +" / " + $elem.SPD.ModuleType
} else {
$MemType = $elem.Type
}

# Note: The JEDEC Spec does not specify how the serial number bytes has to be interpreted (as integer or hex or proprietary).
# Match the iRMC Web Interface which interprets this as unsigned integer.
#$MemSerialNumber = $elem.SPD.ModuleSerialNumber.AsString # hex string version
if ($elem.SPD.ModuleSerialNumber -ne $Null) {
$MemSerialNumber = $elem.SPD.ModuleSerialNumber.InnerText
if ($MemSerialNumber.EndsWith('l')) {
# Work around for a formatting bug in some iRMC Firmware versions (%ul instead of %lu)
$MemSerialNumber = $MemSerialNumber.SubString(0, $MemSerialNumber.Length -1)
}

if ($MemSerialNumber.StartsWith('-')) {
# Work around for another formatting bug in some iRMC Firmware versions (%d instead of %u)
try {
[UInt32]$uVal = [Convert]::ToUInt32($elem.SPD.ModuleSerialNumber.AsString, 16)
$MemSerialNumber = [string]$uVal
} catch {
$MemSerialNumber ='N/A'
}
}
}

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']$")

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ServerName$", $ServerName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/Type$", $MemType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/Size$", $MemSize)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/BusFrequency$", $BusFrequency)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/Voltage$", $elem.SPD.VoltageInterface)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/Manufacturer$", $elem.SPD.ModuleManufacturer)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/ManufacturingDate$", $elem.SPD.ModuleManufacturingDate)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/PartNumber$", $elem.SPD.ModulePartNumber)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/SerialNumber$", $MemSerialNumber)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/RevisionCode$", $elem.SPD.ModuleRevisionCode)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModule']/ConfigStatus$", $ConfigStatus)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $elem.Name)
$discoveryData.AddInstance($instance)

# Memory Group hosts memory
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryGroupHostsMemory']$")
$relationship.Source = $memGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} else {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModuleNotUsable']$")

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ServerName$", $ServerName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryModuleNotUsable']/ConfigStatus$", $ConfigStatus)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $elem.Name)
$discoveryData.AddInstance($instance)

# Memory Group hosts not usable memory
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MemoryGroupHostsMemoryNotUsable']$")
$relationship.Source = $memGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

}

$index++

} else {
# TODO: currently do not report empty memory modules (can be up to 128 Modules)
}
}

# No valid module information detected (BMC has not gotten any information from BIOS during POST)
if ($index -eq 0){
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_MEMORY_INFORMATION_NOT_INITIALIZED -Message ("Memory Information not initialized - please reboot the Fujitsu Out-Of-Band Server")
DebugWarn "$IP - Memory Information not initialized - please reboot the Fujitsu Out-Of-Band Server"
}
} else {
# Every Server has at least one Memory Module or it won't boot.
# Mark Discovery as incomplete if we don't have any Memory information
BailOutAndTestForExisting
}
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Memory Discovery: Exception=$_"
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("Fujitsu Out-Of-Band Server Memory Discovery: Exception=$_ ")
BailOutAndTestForExisting
}

try {
# Fans
if ($faninst -ne $Null -and $faninst.Count -ne 0) {
DebugOut "$IP - has $($fanInst.Count) Fans"
# Fan Group
$groupName = $FanGroupName
$fanGroupInst = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.FanGroup']$")
$fanGroupInst.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$fanGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # key of hosting object

# HealthCollection Class Properties: Get List of devices
$Devices = ""
$DevicesInfo = ""
$index = 0
foreach ($elem in $faninst.Fan) {
$DisplayName = $elem.Name
$Status = $elem.Status.GetAttribute("Description")
if ($Status -ne "not present") {
$DevicesInfo += "$($index): '$($DisplayName)'; "
} else {
if ($IncludeNotPresentFans -eq $True) {
$DevicesInfo += "$($index): '$($DisplayName)' Fan not installed; "
}
}
$index++
}
# Match other MP's Device Info
$Devices = "Fan Devices: $($index)"

$fanGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$" , $IP)
$fanGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$" , $Devices)
$fanGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", $DevicesInfo)

$fanGroupInst.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)
$fanGroupInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $groupName)
$discoveryData.AddInstance($fanGroupInst)

# Fan Group hosted by Server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsFanGroup']$")
$relationship.Source = $serverInstance
$relationship.Target = $fanGroupInst
$discoveryData.AddInstance($relationship)

foreach ($elem in $faninst.Fan) {
$CurrentSpeed = "N/A"
$CurrentMaximalSpeed = "N/A"
$NominalMaximalSpeed = "N/A"

$DisplayName = $elem.Name
$Status = $elem.Status.GetAttribute("Description")
DebugOut "$IP - Fan '$DisplayName' Status: '$Status'"
if ($Status -ne "not present") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.Fan']$")
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ServerName$", $ServerName)

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)

$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $elem.Name)
$discoveryData.AddInstance($instance)

# Fan Group hosts Fan
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.FanGroupHostsFan']$")
$relationship.Source = $fanGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} else {
if ($IncludeNotPresentFans -eq $True) {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.FanNotPresent']$")

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent']/Status$", "Fan not installed")
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $elem.Name)
$discoveryData.AddInstance($instance)

# Group hosts Non Present component
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.FanGroupHostsFanNotPresent']$")
$relationship.Source = $fanGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
}
}
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Fan Discovery: Exception=$_"
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("Fujitsu Out-Of-Band Server Fan Discovery: Exception=$_ ")
BailOutAndTestForExisting
}

try {
# Power Supplies
if ($psuinst -ne $Null -and $psuInst.Count -ne 0) {
DebugOut "$IP - has $($psuInst.Count) Power Supplies"
# Power Supplies Group
$groupName = $PowerSupplyGroupName
$psuGroupInst = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupplyGroup']$")
$psuGroupInst.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$psuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # key of hosting object

# HealthCollection Class Properties: Get List of devices
$Devices = ""
$DevicesInfo = ""
$index = 0
foreach ($elem in $psuinst.PowerSupply) {
$DisplayName = $elem.Name
$Status = $elem.Status.GetAttribute("Description")
if ($Status -ne "not present") {
$DevicesInfo += "$($index): '$($DisplayName)'; "
} else {
if ($IncludeNotPresentPowerSupplies -eq $True) {
$DevicesInfo += "$($index): '$($DisplayName)' PSU not installed; "
}
}
$index++
}
# Match other MP's Device Info
$Devices = "Power Supplies: $($index)"

$psuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$" , $IP)
$psuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$" , $Devices)
$psuGroupInst.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", $DevicesInfo)

$psuGroupInst.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)
$psuGroupInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $groupName)
$discoveryData.AddInstance($psuGroupInst)

# Power Supply Group hosted by Server
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsPowerSupplyGroup']$")
$relationship.Source = $serverInstance
$relationship.Target = $psuGroupInst
$discoveryData.AddInstance($relationship)

$idx = 0
foreach ($elem in $psuinst.PowerSupply) {
$DisplayName = $elem.Name
$Status = $elem.Status.GetAttribute("Description")
DebugOut "$IP - Power Supply '$DisplayName' Status: '$Status'"

if ($Status -ne "not present") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']$")
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareComponent']/ServerName$", $ServerName)

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)

$PsuModel = "N/A"
$PsuVersion = "N/A"
$PsuSerialNumber = "N/A"
$PsuPartNumber = "N/A"
$PsuManufacturer = "N/A"
$PsuManufacturingDate = "N/A"

$a = $fruinst.Class.Instance | where { $_.ClassCode -eq "8" -and $_.Index -eq $idx }
$b = @($a.Data.Decoded.String)
for($i = 0; $i -lt $b.Count; $i++) {
if ($b[$i].ValueID -eq "0800") { $PsuSerialNumber = $b[$i].InnerText}
if ($b[$i].ValueID -eq "0801") { $PsuPartNumber = $b[$i].InnerText}
if ($b[$i].ValueID -eq "0803") { $PsuVersion = $b[$i].InnerText}
if ($b[$i].ValueID -eq "0808") { $PsuModel = $b[$i].InnerText}
if ($b[$i].ValueID -eq "080A") { $PsuManufacturer = $b[$i].InnerText}
if ($b[$i].ValueID -eq "080B") { $PsuManufacturingDate = $b[$i].InnerText}
}

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']/Model$" , $PsuModel)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']/Version$" , $PsuVersion)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']/Manufacturer$" , $PsuManufacturer)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']/ManufacturingDate$", $PsuManufacturingDate)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']/PartNumber$" , $PsuPartNumber)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupply']/SerialNumber$" , $PsuSerialNumber)

$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $elem.Name)
$discoveryData.AddInstance($instance)

# PSU Group hosts PSU
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupplyGroupHostsPowerSupply']$")
$relationship.Source = $psuGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} else {
if ($IncludeNotPresentPowerSupplies -eq $True) {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupplyNotPresent']$")

# key(s) of hosting chain object(s)
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.LogicalHardwareGroup']/ID$", $groupName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentNotPresent']/Status$", "PSU not installed")
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $elem.Name)
$discoveryData.AddInstance($instance)

# Group hosts Non Present component
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerSupplyGroupHostsPowerSupplyNotPresent']$")
$relationship.Source = $psuGroupInst
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
$idx++
}
}
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Power Supply Discovery: Exception=$_"
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("Fujitsu Out-Of-Band Server Power Supply Discovery: Exception=$_ ")
BailOutAndTestForExisting
}

try {

# Other Component Group and Component Status
if ($compInst -ne $Null -and $compinst.HasChildNodes) {

$OtherComponentsGroupDisplayName = "Other Component Status"
$OtherComponentsGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']$")
$OtherComponentsGroupInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$OtherComponentsGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName) # key of hosting object

$OtherComponentsGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName) # key
$OtherComponentsGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $OtherComponentsGroupDisplayName)
$discoveryData.AddInstance($OtherComponentsGroupInstance)

# Server hosts other component status group
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsOtherComponentStatusGroup']$")
$relationship.Source = $serverInstance
$relationship.Target = $OtherComponentsGroupInstance
$discoveryData.AddInstance($relationship)

$a = @( $compinst.Component | where { $_.SensorType -eq "Temperature" } )
if ($a -ne $Null -and $a.Count -gt 0) {
$componentGroupDisplayName ="Temperature Component Status"
$componentGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusTemperatureGroup']$")
# key(s) of hosting object(s) chain
$componentGroupInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)

# HealthCollection Class Properties: Get List of devices
$Devices = ""
$DevicesInfo = ""
$index = 0
for($i = 0; $i -lt $a.Count; $i++){
$DisplayName = $a[$i].Name
$Status = $a[$i].Status.GetAttribute("Description")
$DevicesInfo += "$($index): '$($DisplayName)'; "
$index++
}
# (Try to) match other MP's Device Info
$Devices = "Temperature Component Status: $($index)"

$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$" , $IP)
$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$" , $Devices)
$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", $DevicesInfo)

$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusTemperatureGroup']/ID$", $componentGroupDisplayName ) # key
$componentGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $componentGroupDisplayName)
$discoveryData.AddInstance($componentGroupInstance)

# Server/ Other Component Group hosts component status group
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsTemperatureComponentGroup']$")
$relationship.Source = $serverInstance
$relationship.Target = $componentGroupInstance
$discoveryData.AddInstance($relationship)

for($i = 0; $i -lt $a.Count; $i++){
$DisplayName = $a[$i].Name
$SensorType = $a[$i].SensorType
$EntityIdString = $a[$i].EntityIdString
$EntityInstance = $a[$i].EntityInstance
$Status = $a[$i].Status.GetAttribute("Description")
DebugOut "$IP - Temperature Component Status: '$DisplayName' EntityId: '$EntityIdString' SensorType: '$SensorType' Status: '$Status'"

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.TemperatureComponentStatus']$")

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusTemperatureGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)

$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.TemperatureStatusGroupHostsTemperatureComponentStatus']$")
$relationship.Source = $componentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}

$a = @( $compinst.Component | where { ($_.SensorType -eq "Voltage") -or ($_.SensorType -eq "Battery") } )
if ($a -ne $Null -and $a.Count -gt 0) {
$componentGroupDisplayName = "Voltage Component Status"
$componentGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusVoltageGroup']$")
# key(s) of hosting object(s) chain
$componentGroupInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)

# HealthCollection Class Properties: Get List of devices
$Devices = ""
$DevicesInfo = ""
$index = 0
for($i = 0; $i -lt $a.Count; $i++){
$DisplayName = $a[$i].Name
$Status = $a[$i].Status.GetAttribute("Description")
$DevicesInfo += "$($index): '$($DisplayName)'; "
$index++
}
# (Try to) match other MP's Device Info
$Devices = "Voltage Component Status: $($index)"

$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/ServerName$" , $IP)
$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/Devices$" , $Devices)
$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.HealthCollection']/DevicesInfo$", $DevicesInfo)

$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusVoltageGroup']/ID$", $componentGroupDisplayName ) # key
$componentGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $componentGroupDisplayName)
$discoveryData.AddInstance($componentGroupInstance)

# Server / Other Component Group hosts component status group
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ServerHostsVoltageComponentGroup']$")
$relationship.Source = $serverInstance
$relationship.Target = $componentGroupInstance
$discoveryData.AddInstance($relationship)

# Additional Mainboard / Voltage Group Relationship
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MainboardReferencesVoltageComponentGroup']$")
$relationship.Source = $mainBoardInstance
$relationship.Target = $componentGroupInstance
$discoveryData.AddInstance($relationship)

for($i = 0; $i -lt $a.Count; $i++){
$DisplayName = $a[$i].Name
$SensorType = $a[$i].SensorType
$EntityIdString = $a[$i].EntityIdString
$EntityInstance = $a[$i].EntityInstance
$Status = $a[$i].Status.GetAttribute("Description")
DebugOut "$IP - Voltage Component Status: '$DisplayName' EntityId: '$EntityIdString' SensorType: '$SensorType' Status: '$Status'"

if ($EntityIdString -eq "Battery") {
if ($Status -ne 'Not present') {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.BatteryComponentStatus']$")
# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusVoltageGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

} else {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.BatteryNotPresent']$")
# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusVoltageGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/EntityId$", $EntityIdString) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/EntityInstance$", $EntityInstance) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ServerName$", $ServerName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/Status$", $Status)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

}
} else {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.VoltageComponentStatus']$")
# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusVoltageGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)
}


# Component Status Sub-Group hosts specific component status
if ($EntityIdString -eq "Battery") {
if ($Status -ne 'Not present') {
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.VoltageStatusGroupHostsBatteryComponentStatus']$")
} else {
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.VoltageStatusGroupHostsBatteryNotPresent']$")
}
} else {
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.VoltageStatusGroupHostsVoltageComponentStatus']$")
}
$relationship.Source = $componentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}

# PCI/PCIe Slot Components
$a = @( $compinst.Component | where { $_.SensorType -eq "Critical Interrupt" } )
if ($a -ne $Null -and $a.Count -gt 0) {
$componentGroupDisplayName = "PCIe Slot Component Status"
$componentGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPciSlotGroup']$")
# key(s) of hosting object(s) chain
$componentGroupInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)

$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPciSlotGroup']/ID$", $componentGroupDisplayName ) # key
$componentGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $componentGroupDisplayName)
$discoveryData.AddInstance($componentGroupInstance)

# Other Component Group hosts component status sub-group
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsPciSlotComponentGroup']$")
$relationship.Source = $OtherComponentsGroupInstance
$relationship.Target = $componentGroupInstance
$discoveryData.AddInstance($relationship)

for($i = 0; $i -lt $a.Count; $i++){
$DisplayName = $a[$i].Name
$SensorType = $a[$i].SensorType
$EntityIdString = $a[$i].EntityIdString
$EntityInstance = $a[$i].EntityInstance
$Status = $a[$i].Status.GetAttribute("Description")
DebugOut "$IP - PCIe Slot Component Status: '$DisplayName' EntityId: '$EntityIdString' SensorType: '$SensorType' Status: '$Status'"

if ($Status -ne "Not Present") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PciSlotComponentStatus']$")

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPciSlotGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PciSlotStatusGroupHostsPciSlotComponentStatus']$")
$relationship.Source = $componentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} else {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PciSlotNotPresent']$")

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPciSlotGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/EntityId$", $EntityIdString) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/EntityInstance$", $EntityInstance) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ServerName$", $ServerName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/Status$", "Empty Slot")
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PciSlotStatusGroupHostsPciSlotNotPresent']$")
$relationship.Source = $componentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
}

# Drive Slot Component Status instances
# Note: requires special backplane
$a = @( $compinst.Component | where { $_.SensorType -match "Drive Slot" } )
if ($a -ne $Null -and $a.Count -gt 0) {
$componentGroupDisplayName = "Drive Slot Component Status"
$componentGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusDriveSlotGroup']$")
# key(s) of hosting object(s) chain
$componentGroupInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)

$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusDriveSlotGroup']/ID$", $componentGroupDisplayName ) # key
$componentGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $componentGroupDisplayName)
$discoveryData.AddInstance($componentGroupInstance)

# Other Component Group hosts component status sub-group
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsDriveSlotComponentGroup']$")
$relationship.Source = $OtherComponentsGroupInstance
$relationship.Target = $componentGroupInstance
$discoveryData.AddInstance($relationship)

for($i = 0; $i -lt $a.Count; $i++){
$DisplayName = $a[$i].Name
$SensorType = $a[$i].SensorType
$EntityIdString = $a[$i].EntityIdString
$EntityInstance = $a[$i].EntityInstance
$Status = $a[$i].Status.GetAttribute("Description")
DebugOut "$IP - Drive Slot Component Status: '$DisplayName' EntityId: '$EntityIdString' SensorType: '$SensorType' Status: '$Status'"

if ($Status -ne "Not Present") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.DriveSlotComponentStatus']$")

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusDriveSlotGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.DriveSlotStatusGroupHostsDriveSlotComponentStatus']$")
$relationship.Source = $componentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)

} else {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.DriveSlotNotPresent']$")

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusDriveSlotGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/EntityId$", $EntityIdString) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/EntityInstance$", $EntityInstance) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/ServerName$", $ServerName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusNotPresent']/Status$", "Empty Slot")
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.DriveSlotStatusGroupHostsDriveSlotNotPresent']$")
$relationship.Source = $componentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}
}

# System Management Software Component Status instances
$a = @( $compinst.Component | where { $_.EntityIdString -eq "System Management Software" } )
if ($a -ne $Null -and $a.Count -gt 0) {
$componentGroupDisplayName = "Software Component Status"
$componentGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusMgmtSoftwareGroup']$")
# key(s) of hosting object(s) chain
$componentGroupInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)

$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusMgmtSoftwareGroup']/ID$", $componentGroupDisplayName ) # key
$componentGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $componentGroupDisplayName)
$discoveryData.AddInstance($componentGroupInstance)

# Other Component Group hosts component sub-group
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsMgmtSoftwareComponentGroup']$")
$relationship.Source = $OtherComponentsGroupInstance
$relationship.Target = $componentGroupInstance
$discoveryData.AddInstance($relationship)

for($i = 0; $i -lt $a.Count; $i++){
$DisplayName = $a[$i].Name
$SensorType = $a[$i].SensorType
$EntityIdString = $a[$i].EntityIdString
$EntityInstance = $a[$i].EntityInstance
$Status = $a[$i].Status.GetAttribute("Description")
DebugOut "$IP - Software Component Status: '$DisplayName' EntityId: '$EntityIdString' SensorType: '$SensorType' Status: '$Status'"

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtSoftwareComponentStatus']$")

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusMgmtSoftwareGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtSoftwareStatusGroupHostsMgmtSoftwareComponentStatus']$")
$relationship.Source = $componentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}

# Power Unit Component Status instances
$a = @( $compinst.Component | where { $_.EntityIdString -match "Power Unit" } )
if ($a -ne $Null -and $a.Count -gt 0) {
$componentGroupDisplayName = "Power Unit Components"
$componentGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPowerUnitGroup']$")
# key(s) of hosting object(s) chain
$componentGroupInstance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$componentGroupInstance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)

$componentGroupInstance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPowerUnitGroup']/ID$", $componentGroupDisplayName ) # key
$componentGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $componentGroupDisplayName)
$discoveryData.AddInstance($componentGroupInstance)

# Other Component Group hosts component sub-group
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsPowerUnitComponentGroup']$")
$relationship.Source = $OtherComponentsGroupInstance
$relationship.Target = $componentGroupInstance
$discoveryData.AddInstance($relationship)

for($i = 0; $i -lt $a.Count; $i++){
$DisplayName = $a[$i].Name
$SensorType = $a[$i].SensorType
$EntityIdString = $a[$i].EntityIdString
$EntityInstance = $a[$i].EntityInstance
$Status = $a[$i].Status.GetAttribute("Description")
DebugOut "$IP - Power Unit Component Status: '$DisplayName' EntityId: '$EntityIdString' SensorType: '$SensorType' Status: '$Status'"

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerUnitComponentStatus']$")

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatusPowerUnitGroup']/ID$", $componentGroupDisplayName )

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $DisplayName)
$discoveryData.AddInstance($instance)

# Component Status Sub-Group hosts specific component status
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerUnitStatusGroupHostsPowerUnitComponentStatus']$")
$relationship.Source = $componentGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
}

# Remaining Component Status instances
foreach ($elem in $compinst.Component) {
if ($elem.EntityIdString -eq "Memory Device" -and $elem.SensorType -eq "Memory") { continue } # handled separately
if ($elem.EntityIdString -eq "Processor" -and $elem.SensorType -eq "Processor") { continue } # handled separately
if ($elem.SensorType -eq "Fan") { continue } # handled separately
if ($elem.SensorType -eq "Power Supply") { continue } # handled separately
if ($elem.SensorType -eq "Voltage") { continue } # handled above within Voltages Sub-Group
if ($elem.SensorType -eq "Battery") { continue } # handled above within Voltages Sub-Group
if ($elem.SensorType -eq "Temperature") { continue } # handled above as Sub-Group
if ($elem.SensorType -eq "Critical Interrupt") { continue } # handled above as Sub-Group (PCIe Slots)
if ($elem.SensorType -match "Drive Slot") { continue } # handled above as Sub-Group (Drive Slots)
if ($elem.EntityIdString -match "Power Unit") { continue } # handled above as Sub-Group
if ($elem.EntityIdString -eq "System Management Software") { continue } # handled above as Sub-Group


$DisplayName = $elem.Name
$Status = $elem.Status.GetAttribute("Description")
DebugOut "$IP - Other Component Status: '$DisplayName' EntityId: '$($elem.EntityIdString)' SensorType: '$($elem.SensorType)' Status: '$Status'"

if ($elem.EntityIdString -eq "Power Monitoring") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.PowerMonitoringComponentStatus']$")
} elseif ($elem.EntityIdString -match "System Firmware") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.BiosComponentStatus']$")
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.BiosComponentStatus']/BiosVersion$", $BiosVersion)

} elseif ($elem.EntityIdString -match "System Management Module") {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtCtrlComponentStatus']$")
if ($elem.Name -match 'iRMC') {
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtCtrlComponentStatus']/FirmwareVersion$", $BmcFirmwareVersion)
} else {
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.MgmtCtrlComponentStatus']/FirmwareVersion$", 'N/A')
}
} else {
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatus']$")
}

# key(s) of hosting object(s) chain
$instance.AddProperty("$MPElement[Name='iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice']/IP$", $IP) # host
$instance.AddProperty("$MPElement[Name='FTSLIB!Fujitsu.ServerView.Server']/NetworkName$", $NetworkName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroup']/ID$", $OtherComponentsGroupDisplayName)

$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ID$", $DisplayName) # key
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/SensorType$", $elem.SensorType)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityId$", $elem.EntityIdString)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/EntityInstance$", $elem.EntityInstance)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ManagementUrl$", $hostURL)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/ServerName$", $ServerName)
$instance.AddProperty("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.ComponentStatus']/IP$", $IP)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $elem.Name)
$discoveryData.AddInstance($instance)

# Other Component Group hosts specific component status
if ($elem.EntityIdString -eq "Power Monitoring") {
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsPowerMonitoringComponentStatus']$")
} elseif ($elem.EntityIdString -match "System Firmware") {
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsBiosComponentStatus']$")
} elseif ($elem.EntityIdString -match "System Management Module") {
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsMgmtCtrlComponentStatus']$")
} else {
$relationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='Fujitsu.Servers.PRIMERGY.OutOfBand.OtherComponentStatusGroupHostsOtherComponentStatus']$")
}

$relationship.Source = $OtherComponentsGroupInstance
$relationship.Target = $instance
$discoveryData.AddInstance($relationship)
}
} else {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_NO_COMPONENT_STATUS_INFORMATION -Message ("Component Status Information not available")
DebugWarn "$IP - Component Status Information not available"
BailOutAndTestForExisting
}

} catch {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("Fujitsu Out-Of-Band Server Component Status Discovery: Exception=$_")
DebugErr $SCRIPT_EVENT_NUMBER "$IP - Component Status Discovery: Exception=$_"
BailOutAndTestForExisting
}

DebugOut "$IP - Discovery of Fujitsu Out-Of-Band Server (Legacy) - end"
$discoveryData

}

Function Main {

$IP = $IP.Trim()

Set-CurrentManagementPackVersion -MpName "Fujitsu.Servers.PRIMERGY.OutOfBand"
PrepareLogging -Section $SectionServerDiscovery -HostTag $TagHostsDiscovery -ServerName $IP -CreateSampleLogFile -MpName "Fujitsu.Servers.PRIMERGY.OutOfBand"

DebugOut "$IP - Discovery of Fujitsu Out-Of-Band Server - START"
DebugOut "$IP - Port=$Port TimeoutSeconds=$TimeoutSeconds SkipCACheck=$($SkipCACheck) SkipCNCheck=$($SkipCNCheck)"
DebugOut "$IP - UseDnsNameAsDisplayName=$($UseDnsNameAsDisplayName) UseDnsNameAsNetworkName=$($UseDnsNameAsNetworkName)"
DebugOut "$IP - Include NotPresent Processors=$($IncludeNotPresentProcessors) Fans=$($IncludeNotPresentFans) PowerSupplies=$($IncludeNotPresentPowerSupplies)"

[IPAddress]$IPAddress = $null
if ([System.Net.IPAddress]::tryparse($IP,[ref]$IPAddress)) {
if ($IPAddress.AddressFamily.ToString() -eq "Internetwork") {
$hostURL = "https://" +$IPAddress.ToString() +":$($Port)"
} elseif ($IPAddress.AddressFamily.ToString() -eq "Internetworkv6") {
$hostURL = "https://[" +$IPAddress.ToString() +"]:$($Port)"
}
} else {
LogScriptEventWithEventSource -EventSource "Fujitsu Out-Of-Band" -EventLevel $ERROR_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("Fujitsu Out-Of-Band Server Discovery: Invalid IP Address '$($IP)'")
EarlyExit
}

# First few Monitoring cycles or after the Template has been deleted without properly deleting/removing the discovered items the RunAs account seems not fully assigned
if ([String]::IsNullOrEmpty($UserName) ) {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $INFO_LEVEL -EventNumber $ERROR_NO_USERNAME -Message ("RunAs account information not yet or no longer available")
EarlyExit
}

Redfish_Main

# If we get here Redfish failed / is not available
Legacy_Main

DebugOut "$IP - Discovery of Fujitsu Out-Of-Band Server - END"
# $discoveryData
}

# This script part contains helper functions to perform web based requests
# and is embedded into the final script via Visual Studio Authoring Extensions

[int]$DEFAULT_REQUEST_TIMEOUT = 30 # seconds
[int]$DEFAULT_RETRY_INCREMENT = 10 # seconds
[int]$MAX_REQUEST_RETRIES = 3

[int]$ERROR_SSL_CA_ERROR = 8399 # is not a prime
[int]$ERROR_SSL_CN_ERROR = 8499 # is not a prime

[int]$ERROR_BMC_NO_RESPONSE = 8599 # is a prime
[int]$ERROR_BMC_NO_ACCESS = 8699 # is a prime
[int]$ERROR_BMC_TIMEOUT = 8799 # is not a prime
[int]$ERROR_BMC_NO_PERMISSION = 8899 # is not a prime
[int]$ERROR_BMC_BUSY = 8999 # is a prime

# Subset of possible HTTP error codes
[int]$HTTP_RC_CONTINUE = 100
[int]$HTTP_RC_OK = 200
[int]$HTTP_RC_CREATED = 201
[int]$HTTP_RC_ACCEPTED = 202
[int]$HTTP_RC_NO_CONTENT = 204
[int]$HTTP_RC_RESET_CONTENT = 205
[int]$HTTP_RC_PARTIAL_CONTENT = 206

[int]$HTTP_RC_MULTIPLE_CHOICES = 300
[int]$HTTP_RC_MOVED_PERMANENTLY = 301
[int]$HTTP_RC_MOVED_TEMPORARILY = 302
[int]$HTTP_RC_NOT_MODIFIED = 304

[int]$HTTP_RC_BAD_REQUEST = 400
[int]$HTTP_RC_UNAUTHORIZED = 401
[int]$HTTP_RC_FORBIDDEN = 403
[int]$HTTP_RC_NOT_FOUND = 404
[int]$HTTP_RC_METHOD_NOT_ALLOWED = 405
[int]$HTTP_RC_NOT_ACCEPTABLE = 406
[int]$HTTP_RC_REQ_TIMEOUT = 408

[int]$HTTP_RC_SERVER_ERROR = 500
[int]$HTTP_RC_NOT_IMPLEMENTED = 501
[int]$HTTP_RC_SERVICE_UNAVAILABLE = 503

[bool]$script:SSL_CA_ERROR = $False
[bool]$script:SSL_CN_ERROR = $False
[bool]$script:SSL_NO_CERT_ERROR = $False

[bool]$script:iRMCDetected = $False
[string]$script:WebServer = ""
[System.Net.HttpStatusCode]$script:httpStatusCode = [System.Net.HttpStatusCode]::OK

[System.Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls

[string]$script:AuthData = $Null
[string]$script:Location = $Null
[string]$script:RedfishSession = $Null


$SslCertificateValidator =
{
Param (
[System.Object] $obj,
[System.Security.Cryptography.X509Certificates.X509Certificate] $certificate,
[System.Security.Cryptography.X509Certificates.X509Chain] $chain,
[System.Net.Security.SslPolicyErrors] $errors
)

if ($errors -eq [System.Net.Security.SslPolicyErrors]::None) {
return $True
}

if (($errors -band [System.Net.Security.SslPolicyErrors]::RemoteCertificateChainErrors) -and ($SkipCACheck -eq $False)) {
$script:SSL_CA_ERROR = $True
return $False
}

if (($errors -band [System.Net.Security.SslPolicyErrors]::RemoteCertificateNameMismatch) -and ($SkipCNCheck -eq $False)) {
$script:SSL_CN_ERROR = $True
return $False
}

# No cert provided
if ($errors -band [System.Net.Security.SslPolicyErrors]::RemoteCertificateNotAvailable) {
$script:SSL_NO_CERT_ERROR = $True
return $False
}

# All checks passed
return $True
}

# Will return $Null on error
Function DoWebRequest(
[String]$url,
[string]$Method = "GET",
[string]$AuthType = "Basic",
[System.Net.NetworkCredential]$Credentials = $NetworkCredential ,
[String]$RequestData = $Null,
[int] $RequestTimeout = $DEFAULT_REQUEST_TIMEOUT,
[switch]$IgnoreNoPermission,
[switch]$IgnoreTimeout,
[int] $MaxRetries = $MAX_REQUEST_RETRIES,

[string]$ContentType = "application/json; charset=UTF-8", # default for Redfish
[string]$XAuthData = $Null,
[string]$Etag = $Null
)
{
[bool]$ToggleProxy = $False
if ($MaxRetries -gt $MAX_REQUEST_RETRIES) { $MaxRetries = $MAX_REQUEST_RETRIES }
[int]$retries = 0;
for ($retries = 0; $retries -lt $MaxRetries; $retries++) {
try {
[string]$errorMsg = $Null

$script:SSL_CN_ERROR = $False
$script:SSL_CA_ERROR = $False
$script:SSL_NO_CERT_ERROR = $False

$webRequest = [System.Net.WebRequest]::Create($url)
if ($Credentials -ne $Null) {
if ($AuthType -eq "Basic") {
# Do not wait for the 401 response, send the credentials with the initial request
$AuthData = [Convert]::ToBase64String([Text.Encoding]::Default.GetBytes($Credentials.UserName + ':' + $Credentials.Password));
$webRequest.Headers.Add('Authorization', "Basic $AuthData")

$webRequest.Credentials = $Null
$webRequest.PreAuthenticate = $False
# $webRequest.UseDefaultCredentials = $False
$webRequest.KeepAlive = $False # make sure the connection is not re-used
} else {
$webRequest.Credentials = $Credentials
$webRequest.PreAuthenticate = $True
}
} else {
$webRequest.Credentials = $Null
$webRequest.PreAuthenticate = $False
}
# $webRequest.PreAuthenticate = $False
# $webRequest.UseDefaultCredentials = $false

$webRequest.Timeout = ($RequestTimeout *1000)
$webRequest.ReadWriteTimeout = ($RequestTimeout *1000)
$webRequest.Method = $Method
# $webRequest.Accept = "application/json"
$webRequest.Accept = "*/*"
$webRequest.KeepAlive = $False # make sure the connection is not re-used
$webRequest.AllowAutoRedirect = $False # Do not follow redirects

$webRequest.Headers.Add("OData-Version", "4.0")

# Add only if there is no regular credential
if ($XAuthData.Length -gt 0) {
$webRequest.Headers.Add("X-Auth-Token", $XAuthData)
}

# Add only if present
if ($Etag.Length -gt 0) {
$webRequest.Headers.Add("If-Match", $Etag)
}

# Discovery and Monitoring workflow scripts typically run without a proxy configured.
# Performance Collection workflow scripts typically run with proxy configuration
$Proxy = $WebRequest.Proxy
if ($Proxy) {
$ProxyBypassed = $Proxy.IsBypassed($url)
if ($ProxyBypassed) {
DebugOut "$IP - $($Method) '$($url)' No Proxy (direct connection) will be used"
} else {
$ProxyAddress = $Proxy.GetProxy($url).AbsoluteUri
DebugOut "$IP - $($Method) '$($url)' Proxy '$($ProxyAddress)' will be used"
}
} else {
DebugOut "$IP - $($Method) '$($url)' No Proxy object (direct connection)"
}
if (!$ProxyBypassed -and $ToggleProxy ) {
DebugOut "$IP - $($Method) '$($url)' (Re)Trying without Proxy..."
$webRequest.Proxy = $Null
$ToggleProxy = $False
}

try {
$webRequest.ServicePoint.ConnectionLimit = 128
$webRequest.ServicePoint.ConnectionLeaseTimeout = 0 # Close Connection after servicing a request
$webRequest.ServicePoint.MaxIdleTime = 1 # in MilliSeconds, close connection afterwards
$webRequest.ServerCertificateValidationCallback = $SslCertificateValidator

# DebugOut "$IP - $($Method) '$url' HASH=$($webRequest.ServicePoint.GetHashCode()) ConnectionLimit=$($webRequest.ServicePoint.ConnectionLimit)"
} catch {
DebugErr 9999 "$IP - $($Method) '$url' - Could not set extended config Exception=$_"
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = $SslCertificateValidator
}

if ($RequestData.Length -gt 0) {
$webRequest.ContentType = $ContentType

[bool]$bSendError = $False
[System.Timespan]$reqTime = Measure-Command {
try {
$buffer = [System.Text.Encoding]::UTF8.GetBytes($RequestData)
$webRequest.ContentLength = $buffer.Length;
$requestStream = $webRequest.GetRequestStream()
if ($requestStream) {
$requestStream.Write($buffer, 0, $buffer.Length)
$requestStream.Flush()
$requestStream.Close()
}
} catch [System.Net.WebException] {
$errorMsg = $_.Exception.Message
$stackTrace = $_.Exception.StackTrace
$innerException = $_.Exception.InnerException
$bSendError = $True
} catch {
DebugOut "$IP - $($Method) '$url' could not send request data. Timeout was $($RequestTimeout) seconds. Exception=$_"
$bSendError = $True
}
}

if ($bSendError) {
# If the connection gets closed during early send we retry
# this is typically within a few seconds, otherwise the configured timeout would have expired
if ($reqTime -ne $Null -and [int]$reqTime.TotalSeconds -lt 5) {
[int]$retryDelay = (($retries +1) * $DEFAULT_RETRY_INCREMENT)
if ($errorMsg -ne $Null) { DebugWarn "$IP - $($Method) '$url' could not send request data within $($reqTime.TotalSeconds) seconds - will retry in $retryDelay seconds ($errorMsg)"}
else { DebugWarn "$IP - $($Method) '$url' could not send request data within $($reqTime.TotalSeconds) seconds - will retry in $retryDelay seconds (no details available)"}
if ($innerException -ne $Null) { DebugWarn "InnerException:`r`n$innerException" }
if ($stackTrace -ne $Null ) { DebugWarn "Stack Trace:`r`n$stackTrace" }
Start-Sleep -Seconds $retryDelay
continue
} else {
DebugOut "$IP - $($Method) '$url' could not send request data within $($reqTime.TotalSeconds) seconds. Timeout was $($RequestTimeout) seconds"
# Note: do no report actual timeout seconds here, or alert suppression will not fully work due to different text
if (!$IgnoreTimeout.IsPresent) {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_BMC_TIMEOUT -Message ("'$url' could not send request data. Timeout was $($RequestTimeout) seconds")
}
return
}
}
}

[System.Net.HttpWebResponse] $webResponse = $Null

[System.Timespan]$resTime = Measure-Command {

try {
$webResponse= $webRequest.GetResponse()
} catch [System.Net.WebException] {
$webResponse = $_.Exception.Response
$errorMsg = $_.Exception.Message
$stackTrace = $_.Exception.StackTrace
$innerException = $_.Exception.InnerException
# DebugOut "$IP - '$url' ... Web Exception: $_"
} catch {
$webResponse = $Null
# DebugOut "$IP - '$url' ... Generic Exception: $_"
}
}

# No longer needed ...
$webRequest = $Null

if ($webResponse -ne $Null) {
$script:Location = $webResponse.GetResponseHeader("Location") # $webResponse.Headers.Get("Location")
$script:WebServer = $webResponse.GetResponseHeader("Server") # $webResponse.Headers.Get("Server")
$script:httpStatusCode = $($webResponse.StatusCode.value__)

[System.Net.WebHeaderCollection]$Headers = $webResponse.Headers
if ($Headers) {
[string]$Header = $Headers.Get("X-Auth-Token")
if ($Header.Length -gt 0) {
$script:AuthData = $Header
}

# POST/PUT etc. return created object in 'Location' header, also redirects
if ($Method -ne "GET") {
$Header = $Headers.Get("Location")
if ($Header.Length -gt 0) {
$script:Location = $Header
}
}
}

if ( $script:iRMCDetected -eq $False ){
if ($script:WebServer -match "iRMC") {
$script:iRMCDetected = $True
}
}
$responseStream = New-Object System.IO.StreamReader($webResponse.GetResponseStream())
$result = $responseStream.ReadToEnd()
$responseStream.Close()
$webResponse.Close()

$responseStream = $Null
$webResponse = $Null

switch ( [int]$script:httpStatusCode ) {
$HTTP_RC_OK { # 200
DebugOut "$IP - $($Method) '$url' request handled within $($resTime.TotalSeconds) seconds..."
return $result
}
$HTTP_RC_CREATED { # 201
DebugOut "$IP - $($Method) '$url' resource created within $($resTime.TotalSeconds) seconds (201)..."
return $result
}
$HTTP_RC_ACCEPTED { # 202
DebugOut "$IP - $($Method) '$url' request accepted within $($resTime.TotalSeconds) seconds (202)..."
return $result
}
$HTTP_RC_NO_CONTENT { # 204
DebugOut "$IP - $($Method) '$url' request handled within $($resTime.TotalSeconds) seconds (204 no content)..."
return $result
}
$HTTP_RC_MOVED_PERMANENTLY { # 301
DebugOut "$IP - '$url' permanently redirected to '$($script:Location)' (301)"
if ($script:Location -match "login") {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_BMC_NO_ACCESS -Message ("Invalid credentials")
$script:httpStatusCode = [System.Net.HttpStatusCode]::Unauthorized
}
return
}
$HTTP_RC_MOVED_TEMPORARILY { # 302
DebugOut "$IP - '$url' temporary redirected to '$($script:Location)' (302)"
if ($script:Location -match "login") {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_BMC_NO_ACCESS -Message ("Invalid credentials")
$script:httpStatusCode = [System.Net.HttpStatusCode]::Unauthorized
}
return
}
$HTTP_RC_UNAUTHORIZED { # 401
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_BMC_NO_ACCESS -Message ("Invalid credentials")
return
}
$HTTP_RC_FORBIDDEN { # 403
DebugOut "$IP - $($Method) '$url' No permission (403)..."
if (!$IgnoreNoPermission.IsPresent) {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_BMC_NO_PERMISSION -Message ("No permission (403)")
}
return
}
$HTTP_RC_NOT_FOUND { # 404
return
}
$HTTP_RC_SERVER_ERROR { # 500
return
}
$HTTP_RC_NOT_IMPLEMENTED { # 501
return
}
}

# If we get here some other error occurred (e.g. 503 Service unavailable)
# If this was the first attempt and a proxy was active (e.g. performance collection workflow script), try again without proxy
if (!$ProxyBypassed -and $retries -eq 0) {
DebugOut "$IP - $($Method) '$url' iRMC reported HTTP Status Code ($([int]$script:httpStatusCode) / $($script:httpStatusCode)) - will retry without proxy"
$ToggleProxy = $True
continue
}

if ($retries -lt ($MAX_REQUEST_RETRIES)) {
[int]$retryDelay = (($retries +1) * $DEFAULT_RETRY_INCREMENT)
DebugOut "$IP - $($Method) '$url' iRMC reported HTTP Status Code (($([int]$script:httpStatusCode) / $($script:httpStatusCode)) - will retry in $($retryDelay) seconds"
Start-Sleep -Seconds $retryDelay
continue
} else {
DebugErr $ERROR_BMC_BUSY "$IP - $($Method) '$url' - iRMC reported final HTTP Status Code (($([int]$script:httpStatusCode) / $($script:httpStatusCode)), giving up after retries"
return
}

} else {

# Check for SSL related errors
if ($script:SSL_CN_ERROR -eq $True) {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $INFO_LEVEL -EventNumber $ERROR_SSL_CN_ERROR -Message ("Certificate Common Name (CN) Mismatch")
DebugOut "$IP - '$url' Certificate Name (CN) Mismatch ..."
return
} elseif ($script:SSL_CA_ERROR -eq $True) {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $INFO_LEVEL -EventNumber $ERROR_SSL_CA_ERROR -Message ("Certificate Authority (CA) or Certificate Chain Error")
DebugOut "$IP - '$url' Certificate Authority (CA) or Chain Error ..."
return
} elseif ($script:SSL_NO_CERT_ERROR -eq $True) {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $INFO_LEVEL -EventNumber $ERROR_SSL_ERROR -Message ("No Certificate present")
DebugOut "$IP - '$url' No Certificate present ..."
return
}

# no response (object), check for the timeout value.
# If the connection gets closed during early send/receive,
# this is typically within a few seconds, otherwise the configured timeout would have expired
if ($resTime -ne $Null -and [int]$resTime.TotalSeconds -lt 5) {
[int]$retryDelay = (($retries +1) * $DEFAULT_RETRY_INCREMENT)
if ($retries -ne 0) {
# LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_BMC_NO_RESPONSE -Message ("'$url' no response / connection closed ")
if ($errorMsg -ne $Null) { DebugWarn "$IP - $($Method) '$url' no response / connection closed within $($resTime.TotalSeconds) seconds - will retry in $retryDelay seconds ($errorMsg)"}
else { DebugWarn "$IP - $($Method) '$url' no response / connection closed within $($resTime.TotalSeconds) seconds - will retry in $retryDelay seconds (no details available)"}
if ($innerException -ne $Null) { DebugWarn "InnerException:`r`n$innerException" }
if ($stackTrace -ne $Null ) { DebugWarn "Stack Trace:`r`n$stackTrace" }
}
Start-Sleep -Seconds $retryDelay
} else {
# Note: do no report actual timeout seconds here, or alert suppression will not fully work due to different text
if (!$IgnoreTimeout.IsPresent) {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_BMC_TIMEOUT -Message ("'$url' no response. Timeout was $($RequestTimeout) seconds")
}
DebugOut "$IP - $($Method) '$url' no response within $($resTime.TotalSeconds) seconds. Timeout was $($RequestTimeout) seconds"
return
}
}
} catch {
# LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("'$url' generic Exception=$_")
[int]$retryDelay = (($retries +1) * $DEFAULT_RETRY_INCREMENT)
DebugWarn "$IP - $($Method) '$url' generic Exception. will retry in $retryDelay seconds. Exception=$_"
Start-Sleep -Seconds $retryDelay
}
}
if (!$IgnoreTimeout.IsPresent) {
LogScriptEventWithEventSource -EventSource $IP -EventLevel $WARNING_LEVEL -EventNumber $ERROR_BMC_NO_RESPONSE -Message ("'$url' no response after $retries retries (last error: $errorMsg)")
}
DebugOut "$IP - $($Method) '$url' no response after $retries retries (last error: $errorMsg)"
}



# This script part contains helper functions to perform various logging activities
# and is embedded into the final script via Visual Studio Authoring Extensions

[int]$ERROR_TRACEFILE_XML_PARSE_ERROR = 8299 # is not a prime

# Log an event into the registry, Source will be 'Health Service Script'
# See https://msdn.microsoft.com/en-us/library/bb437630.aspx
[int]$WARNING_LEVEL = 2
[int]$ERROR_LEVEL = 1
[int]$INFO_LEVEL = 0

$LOGFILE_VERSION = "8.5.1.0"

# Generic version
Function RaiseEvent {
Param (
[parameter(Mandatory=$true)]
[string]$EventSource = "Fujitsu Out-Of-Band",
[parameter(Mandatory=$true)]
[int]$EventLevel,
[parameter(Mandatory=$true)]
[int]$EventNumber,
[parameter(Mandatory=$true)]
[string]$Message
)

$channel = "Operations Manager"

if ([System.Diagnostics.EventLog]::SourceExists($EventSource) -eq $False) {
try {
[System.Diagnostics.EventLog]::CreateEventSource($EventSource, $channel)
} catch {

}
}

$eventLog = new-object System.Diagnostics.EventLog -ArgumentList @($channel)
$eventLog.Source = $EventSource

$eventData = @()
$eventData += $EventSource
$eventData += $Message
$eventData += $PoShScriptName

# Note: map different enum values
if($EventLevel -eq $INFO_LEVEL) {
$EventLevel = [System.Diagnostics.EventLogEntryType]::Information
} elseif($EventLevel -eq $WARNING_LEVEL) {
$EventLevel = [System.Diagnostics.EventLogEntryType]::Warning
} elseif($EventLevel -eq $ERROR_LEVEL) {
$EventLevel = [System.Diagnostics.EventLogEntryType]::Error
}

$eventInstance = new-object System.Diagnostics.EventInstance -ArgumentList @($EventNumber, 0, $EventLevel)
$eventLog.WriteEvent($eventInstance, $eventData)
}

Function LogScriptEventWithEventSource {
Param (
[parameter(Mandatory=$true)]
[string]$EventSource = "Fujitsu Out-Of-Band",
[parameter(Mandatory=$true)]
[ValidateRange(0,2)]
[int]$EventLevel,
[parameter(Mandatory=$true)]
[int]$EventNumber,
[parameter(Mandatory=$true)]
[string]$Message
)
DebugOut "Writing Event $($EventNumber) Level=($EventLevel) Source='$($EventSource)' Message='$($Message)'"
if ($ScriptApi -ne $Null) {
$ScriptApi.LogScriptEvent($EventSource, $EventNumber, $EventLevel, $Message)
}
}

# Backwards compatible wrapper
Function LogScriptEvent {
Param (
[parameter(Mandatory=$true)]
[ValidateRange(0,2)]
[int]$EventLevel,
[parameter(Mandatory=$true)]
[int]$EventNumber,
[parameter(Mandatory=$true)]
[string]$Message
)
# Note: Log will be written always with Event Source 'Health Service Script'
if ($ScriptApi -ne $Null) {
# Note: do not use actual script name to consolidate Alert Suppression from parallel scripts
$ScriptApi.LogScriptEvent("Fujitsu Out-Of-Band", $EventNumber, $EventLevel, $Message)
# $ScriptApi.LogScriptEvent($PoShScriptName, $EventNumber, $EventLevel, $Message)
}
}

# Similar, but log with different Event Source ('Health Service Modules Ex') and workflow instance information
Function LogWorkflowEvent {
Param (
[parameter(Mandatory=$true)]
[ValidateRange(0,2)]
[int]$EventLevel,
[parameter(Mandatory=$true)]
[int]$EventNumber,
[parameter(Mandatory=$true)]
[string]$Message
)

$channel = "Operations Manager"
$source = "Health Service Modules Ex"
$eventLog = new-object System.Diagnostics.EventLog -ArgumentList @($channel)
$eventLog.Source = $source

$eventData = @()
$eventData += $global:scriptMG
$eventData += $global:scriptWorkflow
$eventData += $global:scriptInstanceName
$eventData += $global:scriptInstanceId
$eventData += $message
$eventData += $source

if($EventLevel -eq $INFO_LEVEL) {
$EventType = [System.Diagnostics.EventLogEntryType]::Information
} elseif($EventLevel -eq $WARNING_LEVEL) {
$EventType = [System.Diagnostics.EventLogEntryType]::Warning
} elseif($EventLevel -eq $ERROR_LEVEL) {
$EventType = [System.Diagnostics.EventLogEntryType]::Error
}

$eventInstance = new-object System.Diagnostics.EventInstance -ArgumentList @($EventNumber, 0, $EventType)
$eventLog.WriteEvent($eventInstance, $eventData)
}


# set CONSTANT variables (can not be changed):
set-variable -name SVISCOMLogXmlName -value "SVISCOM-OutOfBand.xml" -option constant
set-variable -name SVISCOMLogXm_Name -value "SVISCOM-OutOfBand.xm_" -option constant
set-variable -name SectionRoot -value "root" -option constant
set-variable -name SectionCommentSection -value "CommentSection" -option constant

# Traces for Discoveries
set-variable -name SectionServerDiscovery -value "ServerDiscovery" -option constant
set-variable -name SectionSmashDiscovery -value "SmashDiscovery" -option constant
set-variable -name SectionRaidDiscovery -value "RaidDiscovery" -option constant
set-variable -name SectionPerformanceDiscovery -value "PerformanceDiscovery" -option constant
set-variable -name SectioniRMCDiscovery -value "iRMCDiscovery" -option constant

# Traces for Monitors
set-variable -name SectionHardwareComponentMonitor -value "HardwareComponentsMonitor" -option constant
set-variable -name SectionComponentStatusMonitor -value "ComponentStatusMonitor" -option constant
set-variable -name SectionRaidMonitor -value "RaidMonitor" -option constant
set-variable -name SectionPerformanceMonitor -value "PerformanceMonitor" -option constant
set-variable -name SectioniRMCMonitor -value "iRMCMonitor" -option constant

set-variable -name SectionCommentHosts -value "CommentHosts" -option constant
set-variable -name TagDebugMode -value "DebugMode" -option constant
set-variable -name TagOverWrite -value "OverWrite" -option constant
set-variable -name TagHostsDiscovery -value "HostsForDiscovery" -option constant
set-variable -name TagHostsMonitoring -value "HostsForMonitoring" -option constant

# --------------------------------------------------------------------------
# Global variables = variables, which are changed in different functions ...
# ... and the changed value shall be available in the calling function
# --------------------------------------------------------------------------
$global:DebugMode = $False
$global:DebugFile = $False
$global:OverWrite = $True
$global:DebugHosts = ""
$global:DebugForHost = "$False"
$global:ErrFilePrefix = "ERRORTrace"
$global:WarnFilePrefix = "WARNINGTrace"
$global:LogTargetName = ""
$global:LogFilePrefix = ""
$global:LogFilePath = "$Env:TEMP\SVISCOM\SVISCOM-OutOfBand"
$global:LogFileName = "$LogFilePath\$($LogFilePrefix).log"

$global:MPVERSION = "N/A" # default
$global:MP_NAME = "N/A" # default

# --------------------------------------------------------------------------
Function Set-CurrentManagementPackVersion
{
Param (
[string] $RegistryPath = "HKLM:\SOFTWARE\Fujitsu\ServerView Suite\SCOM Integration\SVISCOM-OutOfBand",
[string] $MpName = "Fujitsu.Servers.PRIMERGY.OutOfBand"
)

if ($RegistryPath -ne $Null -and $MpName -ne $Null) {
# Load SCOM Extensions if not already done
$OMPSInstallKey = "HKLM:\Software\Microsoft\System Center Operations Manager\12\Setup\Powershell\V2"
$regKey = get-item $OMPSInstallKey
$OMPSInstallPath = $regKey.GetValue("InstallDirectory")
$omModule = $OMPSInstallPath + "OperationsManager"
Import-Module -Name $omModule

$MP = Get-SCOMManagementPack -Name $MpName
if ($MP -ne $Null) {
$MpVersion = "$($MP.Version.Major).$($MP.Version.Minor).$($MP.Version.Build).$($MP.Version.Revision)"
DebugOut "'$($MP.DisplayName)' Management Pack Version is $MpVersion"
try {
if (!(Test-Path -Path $RegistryPath)) {
New-Item -Path $RegistryPath | Out-Null
}
Set-ItemProperty -Path $RegistryPath -Name ( "$($MpName).CurrentVersion") -Value $MpVersion -Type String -ErrorAction Stop
} catch {
DebugErr $SCRIPT_EVENT_NUMBER "Error writing Management Pack CurrentVersion. Exception: $_"
}
}
}
}

Function Get-CurrentManagementPackVersion
{
Param (
[string] $RegistryPath = "HKLM:\SOFTWARE\Fujitsu\ServerView Suite\SCOM Integration\SVISCOM-OutOfBand",
[string] $MpName = "Fujitsu.Servers.PRIMERGY.OutOfBand"
)
if ($RegistryPath -ne $Null -and $MpName -ne $Null) {
try {
$regKey = get-item $RegistryPath
$global:MPVERSION = $regKey.GetValue( "$($MpName).CurrentVersion" )
} catch {}
}
}

Function PrepareLogging
{
Param (
[string] $Section,
[string] $HostTag,
[string] $ServerName,
[switch] $CreateSampleLogFile,
[string] $MpName = "Fujitsu.Servers.PRIMERGY.OutOfBand"
)

$global:LogFilePrefix = GiveBaseName $PoShScriptName
$global:MP_NAME = $MpName

# Prepare for IPv6 ...
if ($ServerName.Contains(':') ) {
$IPv6FileName = $ServerName.Replace(":", "_")
$global:LogFileName = "$global:LogFilePath\$($global:LogFilePrefix)Trace_$IPv6FileName.log"
$global:LogTargetName = $IPv6FileName
} else {
$global:LogFileName = "$global:LogFilePath\$($global:LogFilePrefix)Trace_$ServerName.log"
$global:LogTargetName = $ServerName
}

Get-CurrentManagementPackVersion -MpName $MpName

if ($CreateSampleLogFile) {
CreateLogXmlFile
}
if ($global:DebugMode -eq $False) {
GetLogXmlFile $Section $HostTag $ServerName
}

CreateLogFile

# DebugOut "LogFileName = $global:LogFileName"

}

Function GiveBaseName
{
Param (
[string] $in
)

$a = $in.split('.')
Write-Output "$($a[0])"
}

Function CreateLogXmlFile
{
$fileOK = $False
$pathOK = $False
$Xm_FileName = "$global:LogFilePath\$SVISCOMLogXm_Name"

# create the target directory, if it does not exist
if ( ! (Test-Path -Path $global:LogFilePath)) {
New-Item -ItemType directory -Path $global:LogFilePath | Out-Null
}
if (Test-Path -Path $global:LogFilePath) {
$pathOK = $True
}

if (Test-Path -Path $Xm_FileName) {
$txt = Get-Content $Xm_FileName
foreach ($line in $txt) {
if ($line.contains($LOGFILE_VERSION)) {
$fileOK = $True
break
}
}
}

if (($pathOK -eq $True) -and ($fileOK -eq $False)) {
# we write a new SVISCOM-OutOfBand.xm_ file every time the MP is changed to make sure all
# INI-Values are documented for use by the customer if anything changes.
if (Test-Path -Path $Xm_FileName) {
Remove-Item -Path $Xm_FileName -Force | Out-Null
}
#Create xm_ file
New-Item -Path $Xm_FileName -ItemType File | Out-Null

Add-Content -Path $Xm_FileName -Value @"
&lt;$SectionRoot&gt;
&lt;!--
$($SVISCOMLogXmlName) Debug XML file Version $($LOGFILE_VERSION)

With this file logging for PowerShell scripts within the
- Fujitsu Out-Of-Band Management Pack and
- Optional Extension Management Packs for the Fujitsu Out-Of-Band Management Pack
can be enabled.

Rename the file type from '.xm_' to '.xml' to enable reading this file.

Note: You have to enable debug for a script and also select the server in
the '&lt;$TagHostsDiscovery&gt;' or '&lt;$TagHostsMonitoring&gt;' section to generate traces (see below).

The following sections specify for which PowerShell scripts the traces will be generated;
Each of the sections represents a single PowerShell script.

'&lt;$TagDebugMode&gt;' enables logging (yes) or disables logging (no)
'&lt;$TagOverWrite&gt;' defines continuous logging (no) or single script run logging (yes)
--&gt;
&lt;!-- DISCOVERIES --&gt;
&lt;!-- The following section enables trace files for the Out-Of-Band iRMC Device discovery script --&gt;
&lt;$SectioniRMCDiscovery&gt;
&lt;$TagDebugMode&gt;yes&lt;/$TagDebugMode&gt;
&lt;$TagOverWrite&gt;no&lt;/$TagOverWrite&gt;
&lt;/$SectioniRMCDiscovery&gt;

&lt;!-- The following section enables trace files for the Out-Of-Band Server discovery script --&gt;
&lt;$SectionServerDiscovery&gt;
&lt;$TagDebugMode&gt;yes&lt;/$TagDebugMode&gt;
&lt;$TagOverWrite&gt;no&lt;/$TagOverWrite&gt;
&lt;/$SectionServerDiscovery&gt;

&lt;!-- The following section enables trace files for the RAID discovery script --&gt;
&lt;$SectionRaidDiscovery&gt;
&lt;$TagDebugMode&gt;yes&lt;/$TagDebugMode&gt;
&lt;$TagOverWrite&gt;no&lt;/$TagOverWrite&gt;
&lt;/$SectionRaidDiscovery&gt;

&lt;!-- MONITORS --&gt;
&lt;!-- The following section enables trace files for basic iRMC monitoring script --&gt;
&lt;$SectioniRMCMonitor&gt;
&lt;$TagDebugMode&gt;yes&lt;/$TagDebugMode&gt;
&lt;$TagOverWrite&gt;no&lt;/$TagOverWrite&gt;
&lt;/$SectioniRMCMonitor&gt;

&lt;!-- The following section enables trace files for the main server Hardware Components (CPU/Memory/Fan/PowerSupply) monitoring script --&gt;
&lt;$SectionHardwareComponentMonitor&gt;
&lt;$TagDebugMode&gt;yes&lt;/$TagDebugMode&gt;
&lt;$TagOverWrite&gt;no&lt;/$TagOverWrite&gt;
&lt;/$SectionHardwareComponentMonitor&gt;

&lt;!-- The following section enables trace files for the 'Component Status' monitoring script --&gt;
&lt;$SectionComponentStatusMonitor&gt;
&lt;$TagDebugMode&gt;yes&lt;/$TagDebugMode&gt;
&lt;$TagOverWrite&gt;no&lt;/$TagOverWrite&gt;
&lt;/$SectionComponentStatusMonitor&gt;

&lt;!-- The following section enables trace files for the RAID monitoring script --&gt;
&lt;$SectionRaidMonitor&gt;
&lt;$TagDebugMode&gt;yes&lt;/$TagDebugMode&gt;
&lt;$TagOverWrite&gt;no&lt;/$TagOverWrite&gt;
&lt;/$SectionRaidMonitor&gt;

&lt;!-- The following section enables trace files for the Performance monitoring script --&gt;
&lt;$SectionPerformanceMonitor&gt;
&lt;$TagDebugMode&gt;yes&lt;/$TagDebugMode&gt;
&lt;$TagOverWrite&gt;no&lt;/$TagOverWrite&gt;
&lt;/$SectionPerformanceMonitor&gt;

&lt;!--
The following sections specify for which servers the traces will be generated:

In the '&lt;$TagHostsDiscovery&gt;' and '&lt;$TagHostsMonitoring&gt;' sections
single or multiple servers can be specified for verbose debug output
during the discovery and/or during monitoring.

Use '&lt;$TagHostsDiscovery&gt;' for selecting hosts for the discovery trace.
Use '&lt;$TagHostsMonitoring&gt;' for selecting hosts for the monitoring trace.

Use 'all' (without quote signs) for all Fujitsu iRMC / Out-Of-Band Servers monitored by SCOM.
Use a single IP address or a comma separated list to select multiple single servers
Example:
&lt;$TagHostsDiscovery&gt;all&lt;/$TagHostsDiscovery&gt;
&lt;$TagHostsMonitoring&gt;192.168.1.100,192.168.1.101,192.168.1.102&lt;/$TagHostsMonitoring&gt;

will generate discovery traces for all Fujitsu iRMC / Out-Of-Band Servers and
will generate monitoring traces only for servers with the IP address
192.168.1.100 192.168.1.101 and 192.168.1.102
--&gt;
&lt;$TagHostsDiscovery&gt;all&lt;/$TagHostsDiscovery&gt;
&lt;$TagHostsMonitoring&gt;all&lt;/$TagHostsMonitoring&gt;
&lt;/$SectionRoot&gt;
"@
}
}

Function GetLogXmlFile
{
Param (
[string] $Section,
[string] $HostTag,
[string] $ServerName
)

$XmlFileName = "$global:LogFilePath\$SVISCOMLogXmlName"
$ListOfHosts = ""

if (Test-Path -Path $global:LogFilePath) {
if (Test-Path -Path $XmlFileName) {

[string]$xmlData = Get-Content $XmlFileName

if ([string]::IsNullOrWhiteSpace($xmlData)) {
return
}

$xmlDoc = New-Object System.Xml.XmlDocument
try {
if ($xmlDoc.LoadXml($xmlData)) {
LogScriptEventWithEventSource -EventSource "Fujitsu ServerView Integration" -EventLevel $WARNING_LEVEL -EventNumber $ERROR_TRACEFILE_XML_PARSE_ERROR -Message ("XML File '$($XmlFileName)' Parse error: " + [string]($xmlDoc.ParseError))
}
} catch {
# Parsing failed
LogScriptEventWithEventSource -EventSource "Fujitsu ServerView Integration" -EventLevel $WARNING_LEVEL -EventNumber $ERROR_TRACEFILE_XML_PARSE_ERROR -Message ("XML File '$($XmlFileName)' Parse error: $_")
return
}
# Verify basic XML structure
if ( ($xmlDoc.FirstChild.Name -eq $SectionRoot) -and ($xmlDoc.FirstChild.NextSibling -eq $Null)) {
foreach ($node in $xmlDoc.FirstChild.ChildNodes) {
if ($Node.NoteType -eq [System.Xml.XmlNodeType]::Comment) { continue }

if ($Node.Name -eq $section) {
if ($xmlDoc.$SectionRoot.$section.$TagDebugMode -ne $null) {
if ($($xmlDoc.$SectionRoot.$Section.$TagDebugMode).ToUpper() -eq "YES") {
$global:DebugMode = $True
$global:DebugFile = $True
}
}

if ($xmlDoc.$SectionRoot.$section.$TagOverWrite -ne $null) {
if ($($xmlDoc.$SectionRoot.$Section.$TagOverWrite).ToUpper() -eq "NO") {
$global:OverWrite = $False
}
}
break
}
}
}

if ($xmlDoc.$SectionRoot.$HostTag -ne $null) {
$global:DebugHosts = $($xmlDoc.$SectionRoot.$HostTag).ToLower()
}

# Check if DEBUG shall run for this server.
# There are two possibilities to check: "all" server DEBUG is on or this server is in the list.
if ($global:DebugHosts -eq "all") {
$global:DebugForHost = $True
} else {
# Check if this host is in the list of DebugHosts
$ListOfHosts = $($global:DebugHosts).split(',')
DebugOut "Searching for host: $ServerName"
DebugOut "in list of DebugHosts: $global:DebugHosts"

if ($ServerName.ToLower() -in $ListOfHosts) {
$global:DebugForHost = $True
}
}

} # else file does not exist
} # else directory does not exist
}

Function CreateLogFile
{
# For some reason checking for "$True" with "if ($global:a -and $global:b)" is not evaluated correctly!!!
# It works OK in a test with a simple PS script ... no idea why ... Thus we use:
if ($global:DebugForHost -eq $True) {
if ($global:DebugFile -eq $True) {
# Create the target directory, if it does not exist
if (!(Test-Path -Path $global:LogFilePath)) {
New-Item -ItemType directory -Path $global:LogFilePath | Out-Null
}

# Check if file exists and delete if it does and OverWrite is set to TRUE
if (Test-Path -Path $global:LogFileName) {
DebugOut ""
DebugOut "Log file already exists at: $global:LogFileName"
if ($global:OverWrite -eq $True) {
Remove-Item -Path $global:LogFileName -Force | Out-Null
}
}
# If the file has just been removed (OverWrite = YES) or the file does not exist: create it
if (!(Test-Path -Path $global:LogFileName)) {
#Create log file
New-Item -Path $global:LogFileName -ItemType File | Out-Null
}

Add-Content -Path $global:LogFileName -Value @"
********** $(Get-Date -Format F) **********`r
********** $($global:LogFileName) **********`r
********** Management Pack '$($global:MP_NAME)' Version: $($global:MPVERSION)`r
"@
}
}
}

Function DebugOut
{
Param (
[string] $Text
)

if ($global:DebugForHost -eq $True) {
if ($global:DebugMode -eq $True) {
Write-Host $Text
}

if ($global:DebugFile -eq $True) {
if ($global:LogFileName.Length -gt 0) {
if (Test-Path -Path $global:LogFileName) {
$DateTime = Get-Date -format "yyyy-MM-dd HH:mm:ss"
Add-Content -Path $global:LogFileName -Value "$DateTime $Text"
}
}
}
}
}

Function DebugWarn
{
Param (
[string] $Text
)

DebugOut "Warning: $Text"

if ($global:DebugForHost -eq $True) {
if ($global:DebugFile -eq $True) {
$WarnLogFile = "$global:LogFilePath\$($WarnFilePrefix)_$($global:LogTargetName).log"
$DateTime = Get-Date -format "yyyy-MM-dd HH:mm:ss"
Add-Content -Path $WarnLogFile -Value "[$($DateTime)] [$($PoShScriptName)] $($Text)"
}
}
}

Function DebugErr
{
Param (
[int] $ErrNo,
[string] $Text
)

DebugOut "Error: $Text"

if ($global:DebugForHost -eq $True) {
if ($global:DebugFile -eq $True) {
$ErrLogFile = "$global:LogFilePath\$($ErrFilePrefix)_$($global:LogTargetName).log"
$DateTime = Get-Date -format "yyyy-MM-dd HH:mm:ss"
Add-Content -Path $ErrLogFile -Value "[$($ErrNo)] [$($DateTime)] [$($PoShScriptName)] $($Text)"
}
}
}




Main
</Script></ScriptBody>
<!--
Note:
Generating the full System Report used for the discovery can take quite long,
especially when partial System Report is not supported and RAID data is present
-->
<TimeoutSeconds>600</TimeoutSeconds>
<StrictErrorHandling>false</StrictErrorHandling>
<!-- iRMC Access Parameters -->
<IP>$Target/Property[Type="iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice"]/IP$</IP>
<Port>$Target/Property[Type="iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice"]/Port$</Port>
<UserName>$RunAs[Name="iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.MonitoringProfile"]/UserName$</UserName>
<Password>$RunAs[Name="iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.MonitoringProfile"]/Password$</Password>
<SkipCACheck>$Target/Property[Type="iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice"]/SkipCACheck$</SkipCACheck>
<SkipCNCheck>$Target/Property[Type="iRMC!Fujitsu.Servers.PRIMERGY.OutOfBand.iRMC.iRMCDevice"]/SkipCNCheck$</SkipCNCheck>
<!-- Additional Discovery Script Parameters -->
<UseDnsNameAsNetworkName>false</UseDnsNameAsNetworkName>
<UseDnsNameAsDisplayName>true</UseDnsNameAsDisplayName>
<IncludeNotPresentProcessors>true</IncludeNotPresentProcessors>
<IncludeNotPresentFans>true</IncludeNotPresentFans>
<IncludeNotPresentPowerSupplies>true</IncludeNotPresentPowerSupplies>
</DataSource>
</Discovery>