Dell Server Discovery DSMT

Dell.ManagedServer.Discovery.DSMT (DataSourceModuleType)

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DSP DataSource Microsoft.Windows.TimedPowerShell.DiscoveryProvider Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval SecondsInterval for the DSMT script execution
LogLevelint$Config/LogLevel$LogLevelLogLevel for the DSMT script execution
DoDiscoverybool$Config/DoDiscovery$Do DiscoveryFlag to set the Server discovery

Source Code:

<DataSourceModuleType ID="Dell.ManagedServer.Discovery.DSMT" Accessibility="Internal" Batching="false">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>Windows!Microsoft.Windows.PowerShellSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="PrincipalName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="LogLevel" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="DoDiscovery" type="xsd:boolean"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="LogLevel" Selector="$Config/LogLevel$" ParameterType="int"/>
<OverrideableParameter ID="DoDiscovery" Selector="$Config/DoDiscovery$" ParameterType="bool"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DSP" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>DellManagedServerDiscovery.ps1</ScriptName>
<ScriptBody><Script>
param($sourceId,$managedEntityId,$computerName,$LogLevel,$DoDiscovery)
$api = New-Object -comObject 'MOM.ScriptAPI'
$discoveryData = $api.CreateDiscoveryData(0, $sourceId, $managedEntityId)

$scriptname = "DellManagedServerDiscovery"
$logDirectory = "DellManagedServeriSM_log"

if (-not (Get-Module -Name "CimCmdlets")) {
Import-Module -Name "CimCmdlets"
}

try
{
$ErrorActionPreference = "SilentlyContinue"
if ($logLevel -ne 0)
{
$TempFolder = $env:SystemRoot + "\Temp"
$LogLocation = $TempFolder + "\" + $logDirectory + "\"
If(!(Test-Path -path($TempFolder)))
{
# create the directory if not present
New-Item $TempFolder -type directory
}

If(!(Test-Path -path($LogLocation)))
{
# create the directory if not present
New-Item $LogLocation -type directory
}
$Global:LogFileLocation = $LogLocation + $scriptname + ".log"
If(!(Test-Path -path($LogFileLocation)))
{
# create the file if it does not exist
New-Item $LogFileLocation -type file
}
Else
{
$logFileSize = Get-ChildItem $LogFileLocation | ForEach-Object {($_.Length/1KB)}
If ($logFileSize -gt 512)
{
# existingLogFile is greater than 512 KB
$archiveTime = Get-Date -f "yyyy-MM-dd_HH.mm"
Rename-Item $LogFileLocation ("ArchivedLog_" + $scriptname + "_" + $archiveTime + ".log")
New-Item $LogFileLocation ChildItem-type file
}
}
}
}
catch
{
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
$message = "Exception in creating log file. Exception-Message:" + $ErrorMessage + $FailedItem
$api.LogScriptEvent("DellManagedServerDiscovery.ps1",1345,0,$message)
}

Function psDebugLog
{
param($level, $message)
if (($level -gt 0) -and ($level -le $logLevel))
{
$currentTime = Get-Date -f "yyyy-MM-dd_HH.mm.ss"
Out-File -FilePath $LogFileLocation -InputObject ($currentTime + " :: " + $message) -Append
}
}

function get-ServerDiscoveryProceed
{
psDebugLog -level 1 -message "ServerDiscoveryProceed is started"
$strTargetComputer = ($computerName.Split(".")).item(0)
$strEnvComputerName = $env:COMPUTERNAME
psDebugLog -level 1 -message ("Target computer is "+$strTargetComputer)
psDebugLog -level 1 -message ("Env computer is "+$strEnvComputerName)
if($strTargetComputer -ne $strEnvComputerName)
{
psDebugLog -level 1 -message ("Target computer name and computer name from environment is not the same. Exiting discovery.")
return $false
}
if($DoDiscovery -eq $false)
{
psDebugLog -level 1 -message ("DoDiscovery is False, Hence aborting Discovery for "+$computerName)
return $false
}
psDebugLog -level 1 -message "DoDiscovery is enabled - Proceeding with Discovery"
Try
{
$ErrorActionPreference = "SilentlyContinue"
$SystemViewProfile = Get-CimInstance -Namespace root\cimv2\dcim -ClassName "DCIM_SystemView"
if($SystemViewProfile -ne $null)
{
psDebugLog -level 1 -message "ServerDiscoveryProceed returned true"
return $true
}
else
{
psDebugLog -level 1 -message "ServerDiscoveryProceed returned false, SystemViewProfile is NULL"
return $false
}
}
Catch
{
$ErrorMessage = $_.exception.Message
psDebugLog -level 1 -message "Exception in Retriving SystemView Profile Exception-Message:" + $ErrorMessage
return $false
}
}

$MGgroupName = "$Target/ManagementGroup/Name$"
psDebugLog -level 1 -message ("Info: Dell Managed discovery Started for Management Group " + $MGgroupName)
# Update for all profiles inventory.
$profiles = @("DCIM_SystemView",
"DCIM_AggregationMetricValue",
"DCIM_SystemString",
"DCIM_IDRACCardView",
"DCIM_IDRACCardString",
"DCIM_IDRACCardEnumeration",
"DCIM_SoftwareIdentity",
"DCIM_NumericSensor",
"DCIM_Sensor",
"DCIM_HostNetworkInterfaceView",
"DCIM_NICView",
"DCIM_NICString",
"DCIM_NICCapabilities",
"DCIM_PowerSupplyView",
"DCIM_vFlashView",
"DCIM_CPUView",
"DCIM_MemoryView",
"DCIM_License",
"DCIM_ControllerView",
"DCIM_EnclosureView",
"DCIM_VirtualDiskView",
"DCIM_ControllerBatteryView",
"DCIM_EnclosureEMMView",
"DCIM_EnclosureTemperatureSensor",
"DCIM_EnclosureFanSensor",
"DCIM_PhysicalDiskView",
"DCIM_EnclosurePSUView",
"DCIM_PCIeSSDExtenderView",
"DCIM_PCIeSSDBackPlaneView",
"DCIM_PCIeSSDView",
"DCIM_RAIDEnumeration",
"DCIM_SwitchConnectionView",
"DCIM_PresenceAndStatusSensor"
)

$hash_profileInstances = @{}

$serverDiscoveryProceed = get-ServerDiscoveryProceed
If($false -eq $serverDiscoveryProceed)
{
Submit-EmptyDiscoveryData
}
else
{
foreach($profile in $profiles)
{
psDebugLog -level 1 -message ("Retriving " + $profile + " Profile")
Try
{
$ErrorActionPreference = "SilentlyContinue"
$ProfileInstances = Get-CimInstance -Namespace root\cimv2\dcim -ClassName $profile
#Converting single-objects into arrays, as some profiles are not arrrays
if($ProfileInstances -ne $null)
{
psDebugLog -level 1 -message ("Profile CIM Query SUCCESSFULLY retrieved " + $profile)
if($ProfileInstances -isnot [system.array])
{
$temparray = @()
$temparray += $ProfileInstances
$ProfileInstances = $temparray
}
# Then add array into Hash Map.
$hash_profileInstances.Add($profile, $ProfileInstances)
}
else
{
psDebugLog -level 1 -message ("Profile CIM Query returned NULL " + $profile)
}
}
Catch{
$ErrorMessage = $_.Exception.Message
psDebugLog -level 1 -message ("Exception in Retriving Profile " + $profile + " Exception-Message:" + $ErrorMessage)
}
}
}

$dcimSystemViewArray = $hash_profileInstances.Item("DCIM_SystemView")
$dcimSystemView = $null
if($dcimSystemViewArray -ne $null){
$dcimSystemView = $dcimSystemViewArray[0];
}
$dcimSystemStringArray = $hash_profileInstances.Item("DCIM_SystemString")
$dcimPowerSupplyViewArray = $hash_profileInstances.Item("DCIM_PowerSupplyView")
$dcimiDracCardViewArray = $hash_profileInstances.Item("DCIM_IDRACCardView")
$dcimiDracCardStringArray = $hash_profileInstances.Item("DCIM_IDRACCardString")
$dcimiDracCardEnumerationArray = $hash_profileInstances.Item("DCIM_IDRACCardEnumeration")
$dcimSoftIdViewArray = $hash_profileInstances.Item("DCIM_SoftwareIdentity")
$dcimNumSensorViewArray = $hash_profileInstances.Item("DCIM_NumericSensor")
$dcimSensorViewArray = $hash_profileInstances.Item("DCIM_Sensor")
$dcimHostNicViewArray = $hash_profileInstances.Item("DCIM_HostNetworkInterfaceView")
$dcimNicViewArray = $hash_profileInstances.Item("DCIM_NICView")
$dcimNicStringArray = $hash_profileInstances.Item("DCIM_NICString")
$dcimNicCapabilitiesArray = $hash_profileInstances.Item("DCIM_NICCapabilities")
$dcimSdcardViewArray = $hash_profileInstances.Item("DCIM_vFlashView")
$dcimProcInstArray = $hash_profileInstances.Item("DCIM_CPUView")
$dcimMemInstArray = $hash_profileInstances.Item("DCIM_MemoryView")
$dcimLicensegrpInstArray = $hash_profileInstances.Item("DCIM_License")
$dcimControllergrpInstArray = $hash_profileInstances.Item("DCIM_ControllerView")
$dcimEnclosureViewArray = $hash_profileInstances.Item("DCIM_EnclosureView")
$dcimEnclosureEMMViewArray = $hash_profileInstances.Item("DCIM_EnclosureEMMView")
$dcimVirtualDiskArray = $hash_profileInstances.Item("DCIM_VirtualDiskView")
$dcimControllerBatteryArray = $hash_profileInstances.Item("DCIM_ControllerBatteryView")
$dcimEnclosureTempSensorArray = $hash_profileInstances.Item("DCIM_EnclosureTemperatureSensor")
$dcimEnclosureFanSensorArray = $hash_profileInstances.Item("DCIM_EnclosureFanSensor")
$dcimPhysicalDiskViewArray = $hash_profileInstances.Item("DCIM_PhysicalDiskView")
$dcimEnclosurePSUViewArray = $hash_profileInstances.Item("DCIM_EnclosurePSUView")
$dcimPCIeSSDExtenderViewArray = $hash_profileInstances.Item("DCIM_PCIeSSDExtenderView")
$dcimPCIeSSDBackPlaneViewArray = $hash_profileInstances.Item("DCIM_PCIeSSDBackPlaneView")
$dcimPCIeSSDViewArray = $hash_profileInstances.Item("DCIM_PCIeSSDView")
$dcimRAIDEnumeration = $hash_profileInstances.Item("DCIM_RAIDEnumeration")
$dcimSwitchConnectionViewArray = $hash_profileInstances.Item("DCIM_SwitchConnectionView")
$dcimAggregationMetricValueArray = $hash_profileInstances.Item("DCIM_AggregationMetricValue")
$dcimPresenceAndStatusSensorArray = $hash_profileInstances.Item("DCIM_PresenceAndStatusSensor")

function formatString
{
param($varString)
psDebugLog -level 2 -message ("Entered FormatString Function with "+$varString)
$retString = "Not Available"
if($varString -is [system.array])
{
if($varString.count -gt 0)
{
psDebugLog -level 2 -message ("FormatString Function varString is an Array of length "+$varString.count)
$retString = [string]::Join(",", $varString)
}
}
else
{
if(!([string]::IsNullOrEmpty($varString)))
{
$retString = $varString
}
}
psDebugLog -level 2 -message ("FormatString Function returned "+$retString)
return $retString
}

function addSCOMPropertyFromHash()
{
param($bundle, $classInstance)
foreach ($h in $bundle.GetEnumerator())
{
#Write-Host "$($h.Name): $($h.Value)"
$a = [System.Array]$h.Value
$attributeVal = $a[1]
if($a[2] -eq $true)
{
$attributeVal = formatString($a[1])
}
psDebugLog -level 2 -message "Adding Property &gt;&gt;&gt; $($h.Name) --- $attributeVal"
$classInstance.addProperty($a[0], $attributeVal)
}
}

function convertMemorySize
{
param($memSizeStr, [int]$unit)

$retMemSizeStr = "Not Available"
if([string]::IsNullOrEmpty($memSizeStr))
{
return $retMemSizeStr
}

$memSizeDouble = [double]$memSizeStr
$unitVal = 1024
$MemUnits = @(" Bytes"," KB"," MB"," GB"," TB"," PB")
#use these while calling 0-Bytes,1-KB,2-MB,3-GB,4-TB,5-PB
#hardcode 1023 if required
if($memSizeDouble -lt $unitVal)
{
$retMemSizeStr = [string]$memSizeDouble + $MemUnits[$unit]
}
else
{
$convFlag = $false
for($unitIter=$unit+1; $unitIter -lt $MemUnits.Length; $unitIter++)
{
if( ($memSizeDouble -ge [double]($unitVal) ) -and ($memSizeDouble -lt ([double]($unitVal*1024) ) ) )
{
$value = [double]($memSizeDouble/$unitVal)
$retMemSizeStr = [string]([Math]::Round($value, 2,[MidPointRounding]::AwayFromZero)) + $MemUnits[$unitIter]
$convFlag = $true
break
}
$unitVal = $unitVal * 1024
}
if(!$convFlag){
$value = [double]($memSizeDouble/$unitVal)
$retMemSizeStr = [string]([Math]::Round($value, 2,[MidPointRounding]::AwayFromZero)) + $MemUnits[5]
}
}
return $retMemSizeStr
}

function get-relationshipObject{
param($relationshipObjectPar)
psDebugLog -level 1 -message "get-relationshipObject is started"
$relationshipInst = $discoveryData.CreateRelationshipInstance($relationshipObjectPar[0])
$relationshipInst.Source = $relationshipObjectPar[1]
$relationshipInst.Target = $relationshipObjectPar[2]
$discoveryData.AddInstance($relationshipInst)
psDebugLog -level 1 -message "get-relationshipObject is Ended"
}

$Script:serverUID = formatString($dcimSystemView.ServiceTag)
$serviceTag = $serverUID
$storageTreeMap = @{}
[int]$Script:storageTreeIditer = 0
[int]$Script:vFlashStorageSize = 0

function get-ManagedServerDiscovery
{
$ServerInst = $null
psDebugLog -level 1 -message "get-ManagedServerDiscovery is Started "
#TBD:: Create a function to initialize Hash Map Profile output.
If($dcimSystemView -ne $null)
{
$manufacturer = $dcimSystemView.Manufacturer.ToLower().trim()

$chassisServiceTag = $dcimSystemView.ChassisServiceTag
$model = $dcimSystemView.Model
$systemGeneration = $dcimSystemView.SystemGeneration.trim()
$urlString = $dcimiDracCardViewArray[0].URLString
$serviceTag = $dcimSystemView.ServiceTag

If(($systemGeneration -ne "") -and (($manufacturer.Contains("dell ")) -or ($manufacturer.Contains("dell")) -or ($manufacturer -eq ""))){
$generation = $systemGeneration.split(" ")[0].replace("G","")
if($generation -gt 11){
if($systemGeneration.split(" ")[1] -eq "Monolithic"){
$ServerInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MonolithicServer']$")
psDebugLog -level 1 -message "Server is monolithic"
}
elseif($model.Contains("PowerEdge FC")){
$ServerInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.SledServer']$")
psDebugLog -level 1 -message "Server is sled Server"
}
elseif($model.Contains("PowerEdge FM")){
$ServerInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.SledNode']$")
$Script:serverUID = formatString($dcimSystemView.NodeID)
psDebugLog -level 1 -message "Server is FM Sled server"
}
elseif($systemGeneration.split(" ")[1] -eq "Modular"){
$ServerInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ModularBlade']$")
psDebugLog -level 1 -message "Server is modular"
}
elseif($systemGeneration.split(" ")[1] -eq "DCS"){
$ServerInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MonolithicServer']$")
psDebugLog -level 1 -message "Server is monolithic"
}
elseif($chassisServiceTag -eq $serviceTag){
$ServerInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ModularBlade']$")
psDebugLog -level 1 -message "Server is modular"
}
else{
$ServerInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MonolithicServer']$")
psDebugLog -level 1 -message "Server is monolithic (default)"
}
#$ServerInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer']$")

[string] $OSName = ''
[string] $OSVersion = ''
Foreach($sysStringProf in $dcimSystemStringArray)
{
if($sysStringProf.AttributeName -eq "OSName")
{
$OSName = $sysStringProf.CurrentValue
}
if($sysStringProf.AttributeName -eq "OSVersion")
{
$OSVersion = $sysStringProf.CurrentValue
}
}

$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$attributeVal = formatString($dcimSystemView.HostName)
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/HostName$", $attributeVal)
$attributeVal = formatString($urlString)
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/RACURL$", $attributeVal)
$attributeVal = formatString($dcimSystemView.AssetTag)
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/AssetTag$", $attributeVal)
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/ServiceTag$", $serviceTag)
$attributeVal = formatString($dcimSystemView.ExpressServiceCode)
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/ExpressServiceCode$", $attributeVal)
$attributeVal = formatString($dcimSystemView.Manufacturer)
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/Manufacturer$", $attributeVal)
$attributeVal = formatString($model)
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/Model$", $attributeVal)
$attributeVal = formatString($systemGeneration)
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/ServerGeneration$", $attributeVal)
$attributeVal = formatString($chassisServiceTag)
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/ChassisServiceTag$", $attributeVal)
$attributeVal = formatString($dcimSystemView.BIOSVersionString)
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/BIOSVersion$", $attributeVal)
$attributeVal = convertMemorySize -memSizeStr $dcimSystemView.SysMemTotalSize -unit 2
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/TotalMemory$", $attributeVal)
$attributeVal = formatString($dcimSystemView.BoardPartNumber)
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/BoardPartNumber$", $attributeVal)
$attributeVal = formatString($OSName)
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/OperatingSystem$", $attributeVal)
$attributeVal = formatString($OSVersion)
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/OperatingSystemVersion$", $attributeVal)
$attributeVal = formatString($dcimSystemView.NodeID)
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/NodeID$", $attributeVal)
$attributeVal = convertMemorySize -memSizeStr $dcimSystemView.SysMemMaxCapacitySize -unit 2
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/MaxMemoryCapacity$", $attributeVal)
$attributeVal = formatString($computerName)
$ServerInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $attributeVal)
$attributeVal = "Not Applicable"
if(($dcimiDracCardEnumerationArray -ne $null) -and ($dcimiDracCardEnumerationArray.count -gt 0)){
foreach($dcimiDracCardEnumeration in $dcimiDracCardEnumerationArray){
if($dcimiDracCardEnumeration.AttributeName -eq "SystemLockdown"){
$attributeVal = formatString($dcimiDracCardEnumeration.CurrentValue)
break
}
}
}
$ServerInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/SystemLockdown$", $attributeVal)
$discoveryData.AddInstance($ServerInst)

#instance of the HealthService class.
psDebugLog -level 1 -message ("CREATING Health Service of "+$computerName)
$healthServiceInstance = $discoveryData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$" )
$healthServiceInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
$discoveryData.AddInstance($healthServiceInstance)
psDebugLog -level 1 -message ("CREATING HSSME with HS of "+$computerName)

#instance of the HealthServiceShouldManageEntity class.
$healthServiceRelationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
$healthServiceRelationship.Source = $healthServiceInstance
$healthServiceRelationship.Target = $ServerInst
$discoveryData.AddInstance($healthServiceRelationship)

}
else
{
psDebugLog -level 1 -message "Server Generation Unsupported (&lt;11) "
}
}
else
{
psDebugLog -level 1 -message "ServerGeneration is empty"
psDebugLog -level 1 -message "Manufacturer is not Dell"
}
}
else
{
psDebugLog -level 1 -message "iSM is not found, pls check iSM is installed"
}
psDebugLog -level 1 -message "get-ManagedServerDiscovery is Ended "
return $ServerInst
}
$cpuFamilyMap = @{"1" = "Other";
"2" = "Unknown";
"3" = "8086";
"4" = "80286";
"5" = "80386";
"6" = "80486";
"7" = "8087";
"8" = "80287";
"9" = "80387";
"A" = "80487";
"B" = "Pentium(R)brand";
"C" = "Pentium(R)Pro";
"D" = "pentium(R) II";
"E" = "Pentium(R) Processor with MMX(TM) technology";
"F" = "Celeron(TM)";
"10" = "Pentium(R) II Xeon(TM)";
"11" = "Pentium(R) III";
"12" = "M1 Family";
"13" = "M2 Family";
"14" = "Intel(R) Celeron(R) M processor";
"15" = "Intel(R) Pentium(R) 4 HT processor";
"18" = "K5 Family";
"19" = "K6 Family" ;
"1A" = "K6-2";
"1B" = "K6-3";
"1C" = "AMD Athlon(TM) Processor Family";
"1D" = "AMD(R) Duron(TM) Processor";
"1E" = "AMD29000 Family";
"1F" = "K6-2+";
"20" = "Power PC Family";
"21" = "Power PC 601";
"22" = "Power PC 603";
"23" = "Power PC 603+";
"24" = "Power PC 604";
"25" = "Power PC 620";
"26" = "Power PC X704";
"27" = "Power PC 750";
"28" = "Intel(R) Core(TM) Duo processor";
"29" = "Intel(R) Core(TM) Duo mobile processor";
"2A" = "Intel(R) Core(TM) Solo mobile processor";
"2B" = "Intel(R) Atom(TM) processor";
"30" = "Alpha Family";
"31" = "Alpha 21064";
"32" = "Alpha 21066";
"33" = "Alpha 21164";
"34" = "Alpha 21164PC";
"35" = "Alpha 21164a";
"36" = "Alpha 21264";
"37" = "Alpha 21364";
"38" = "AMD Turion(TM) II Ultra Dual-Core Mobile M Processor Family";
"39" = "AMD Turion(TM) II Dual-Core Mobile M Processor Family";
"3A" = "AMD Athlon(TM) II Dual-Core Mobile M Processor Family";
"3B" = "AMD Opteron(TM) 6100 Series Processor";
"3C" = "AMD Opteron(TM) 4100 Series Processor";
"3D" = "AMD Opteron(TM) 6200 Series Processor";
"3E" = "AMD Opteron(TM) 4200 Series Processor";
"40" = "MIPS Family";
"41" = "MIPS R4000";
"42" = "MIPS R4200";
"43" = "MIPS R4400";
"44" = "MIPS R4600";
"45" = "MIPS R10000";
"46" = "AMD C-Series Processor";
"47" = "AMD E-Series Processor";
"48" = "AMD S-Series Processor";
"49" = "AMD G-Series Processor";
"50" = "SPARC Family";
"51" = "SuperSPARC";
"52" = "microSPARC II";
"53" = "microSPARC IIep";
"54" = "UltraSPARC";
"55" = "UltraSPARC II";
"56" = "UltraSPARC IIi";
"57" = "UltraSPARC III";
"58" = "UltraSPARC IIIi";
"60" = "68040";
"61" = "68xxx Family";
"62" = "68000";
"63" = "68010";
"64" = "68020";
"65" = "68030";
"70" = "Hobbit Family"
"78" = "Crusoe(TM) TM5000 Family";
"79" = "Crusoe(TM) TM3000 Family";
"7A" = "Efficeon(TM) TM8000 Family";
"80" = "Weitek";
"82" = "Itanium(TM) Processor";
"83" = "AMD Athlon(TM) 64 Processor Family";
"84" = "AMD Opteron(TM) Processor Family";
"85" = "AMD Sempron(TM) Processor Family";
"86" = "AMD Turion(TM) 64 Mobile Technology";
"87" = "Dual-Core AMD Opteron(TM) Processor Family";
"88" = "AMD Athlon(TM) 64 X2 Dual-Core Processor Family";
"89" = "AMD Turion(TM) 64 X2 Mobile Technology";
"8A" = "Quad-Core AMD Opteron(TM) Processor Family";
"8B" = "Third Generation AMD Opteron(TM) Processor Family";
"8C" = "AMD Phenom(TM) FX Quad-Core Processor Family";
"8D" = "AMD Phenom(TM) X4 Quad-Core Processor Family";
"8E" = "AMD Phenom(TM) X2 Dual-Core Processor Family";
"8F" = "AMD Athlon(TM) X2 Dual-Core Processor Family";
"90" = "PA-RISC Family";
"91" = "PA-RISC 8500";
"92" = "PA-RISC 8000";
"93" = "PA-RISC 7300LC";
"94" = "PA-RISC 7200";
"95" = "PA-RISC 7100LC";
"96" = "PA-RISC 7100";
"A0" = "V30 Family";
"A1" = "Quad-Core Intel(R) Xeon(R) processor 3200 Series";
"A2" = "Dual-Core Intel(R) Xeon(R) processor 3000 Series";
"A3" = "Quad-Core Intel(R) Xeon(R) processor 5300 Series";
"A4" = "Dual-Core Intel(R) Xeon(R) processor 5100 Series";
"A5" = "Dual-Core Intel(R) Xeon(R) processor 5000 Series";
"A6" = "Dual-Core Intel(R) Xeon(R) processor LV";
"A7" = "Dual-Core Intel(R) Xeon(R) processor ULV";
"A8" = "Dual-Core Intel(R) Xeon(R) processor 7100 Series";
"A9" = "Quad-Core Intel(R) Xeon(R) processor 5400 Series";
"AA" = "Quad-Core Intel(R) Xeon(R) processor";
"AB" = "Dual-Core Intel(R) Xeon(R) processor 5200 Series";
"AC" = "Dual-Core Intel(R) Xeon(R) processor 7200 Series";
"AD" = "Quad-Core Intel(R) Xeon(R) processor 7300 Series";
"AE" = "Quad-Core Intel(R) Xeon(R) processor 7400 Series";
"AF" = "Multi-Core Intel(R) Xeon(R) processor 7400 Series";
"B0" = "Pentium(R) III Xeon(TM)";
"B1" = "Pentium(R) III Processor with Intel(R) SpeedStep(TM) Technology";
"B2" = "Pentium(R) 4";
"B3" = "Intel(R) Xeon(TM)";
"B4" = "AS400 Family";
"B5" = "Intel(R) Xeon(TM) Processor MP";
"B6" = "AMD Athlon(TM) XP Family";
"B7" = "AMD Athlon(TM) MP Family";
"B8" = "Intel(R) Itanium(R) 2";
"B9" = "Intel(R) Pentium(R) M Processor";
"BA" = "Intel(R) Celeron(R) D Processor";
"BB" = "Intel(R) Pentium(R) D Processor";
"BC" = "Intel(R) Pentium(R) Processor Extreme Edition";
"BD" = "Intel(R) Core(TM) Solo Processor";
"BE" = "K7";
"BF" = "Intel(R) Core(TM) 2 Duo Processor";
"C0" = "Intel(R) Core(TM) 2 Solo Processor";
"C1" = "Intel(R) Core(TM) 2 Extreme Processor";
"C2" = "Intel(R) Core(TM) 2 Quad Processor";
"C3" = "Intel(R) Core(TM) 2 Extreme mobile Processor";
"C4" = "Intel(R) Core(TM) 2 Duo mobile Processor";
"C5" = "Intel(R) Core(TM) 2 solo mobile Processor";
"C6" = "Intel(R) Core(TM) i7 processor";
"C7" = "Dual-Core Intel(R) Celeron(R) Processor";
"C8" = "S/390 and zSeries Family";
"C9" = "ESA/390 G4";
"CA" = "ESA/390 G5";
"CB" = "ESA/390 G6";
"CC" = "z/Architecture base";
"CD" = "Intel(R) Core(TM) i5 processor";
"CE" = "Intel(R) Core(TM) i3 processor";
"D2" = "VIA C7(TM)-M Processor Family";
"D3" = "VIA C7(TM)-D Processor Family";
"D4" = "VIA C7(TM) Processor Family";
"D5" = "VIA Eden(TM) Processor Family";
"D6" = "Multi-Core Intel(R) Xeon(R) processor";
"D7" = "Dual-Core Intel(R) Xeon(R) processor 3xxx Series";
"D8" = "Quad-Core Intel(R) Xeon(R) processor 3xxx Series";
"D9" = "VIA Nano(TM) Processor Family";
"DA" = "Dual-Core Intel(R) Xeon(R) processor 5xxx Series";
"DB" = "Quad-Core Intel(R) Xeon(R) processor 5xxx Series";
"DD" = "Dual-Core Intel(R) Xeon(R) processor 7xxx Series";
"DE" = "Quad-Core Intel(R) Xeon(R) processor 7xxx Series";
"DF" = "Multi-Core Intel(R) Xeon(R) processor 7xxx Series";
"E0" = "Multi-Core Intel(R) Xeon(R) processor 3400 Series";
"E6" = "Embedded AMD Opteron(TM) Quad-Core Processor Family";
"E7" = "AMD Phenom(TM) Triple-Core Processor Family";
"E8" = "AMD Turion(TM) Ultra Dual-Core Mobile Processor Family";
"E9" = "AMD Turion(TM) Dual-Core Mobile Processor Family";
"EA" = "AMD Athlon(TM) Dual-Core Processor Family";
"EB" = "AMD Sempron(TM) SI Processor Family";
"EC" = "AMD Phenom(TM) II Processor Family";
"ED" = "AMD Athlon(TM) II Processor Family";
"EE" = "Six-Core AMD Opteron(TM) Processor Family";
"EF" = "AMD Sempron(TM) M Processor Family";
"FA" = "i860";
"FB" = "i960";
"FE" = "Reserved (SMBIOS Extension)";
"FF" = "Reserved (Un-initialized Flash Content - Lo)";
"104" = "SH-3";
"105" = "SH-4";
"118" = "ARM";
"119" = "StrongARM";
"12C" = "6x86";
"12D" = "MediaGX";
"12E" = "MII";
"140" = "WinChip";
"15E" = "DSP";
"1F4" = "Video Processor";
"FFFE" = "Reserved (For Future Special Purpose Assignment)";
"FFFF" = "Reserved (Un-initialized Flash Content - Hi)";
"E5" = "AMD AMD Sempron(TM) II Processor";
"66" = "AMD Athlon(TM) X4 Quad-Core Processor Family";
"3F" = "AMD FX(TM) Series Processor";
"4F" = "AMD FirePro(TM) Series Processor";
"E4" = "AMD Opteron(TM) 3000 Series Processor";
"4E" = "AMD Opteron(TM) 3300 Series Processor";
"4C" = "AMD Opteron(TM) 4300 Series Processor";
"4D" = "AMD Opteron(TM) 6300 Series Processor";
"69" = "AMD Opteron(TM) A-Series Processor";
"67" = "AMD Opteron(TM) X1000 Series Processor";
"68" = "AMD Opteron(TM) X2000 Series APU";
"6A" = "AMD Opteron(TM) X3000 Series APU";
"4B" = "AMD R-Series Processor";
"4A" = "AMD Z-Series Processor";
"6B" = "AMD Zen Processor Family";
"2C" = "Intel(R) Core(TM) M processor";
"2D" = "Intel(R) Core(TM) m3 processor";
"2E" = "Intel(R) Core(TM) m5 processor";
"2F" = "Intel(R) Core(TM) m7 processor"}
$characteristicsMap = @{"4" = "64-bit capable";
"2" = "Unknown"}

$CapableEnabledMap = @{ 0 = "No";
1 = "Yes";
2 = "Not Applicable"}
function get-ServerProcessorDiscovery
{
psDebugLog -level 1 -message "get-ServerProcessorDiscovery is Started "
$procinst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Processors']$")
psDebugLog -level 1 -message "serverUID : " + $serverUID
$procinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$procinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Processors']/ID$", "Processor Group")
$procinst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Processor Group")
$discoveryData.AddInstance($procinst)
foreach($dcimProcInst in $dcimProcInstArray)
{
get-ServerProcInstDiscovery -dcimProcInst $dcimProcInst
}
psDebugLog -level 1 -message "get-ServerProcessorDiscovery is Ended "
}

function get-ServerProcInstDiscovery
{
param($dcimProcInst)
$procDeviceID = formatString($dcimProcInst.FQDD)
$cpuFamily = formatString($dcimProcInst.CPUFamily)
$actualCPUFamily = $cpuFamilyMap.Item( $cpuFamily )
if($actualCPUFamily -eq $null)
{
$actualCPUFamily = "Not Available"
}

[float]$cpuMaxClockSpeed = $dcimProcInst.MaxClockSpeed
if($cpuMaxClockSpeed -ne "Not Available")
{
if($cpuMaxClockSpeed -le 1000)
{
$actualMaxClockSpeed = $cpuMaxClockSpeed.ToString() + " MHz"
}
elseif($cpuMaxClockSpeed -gt 1000 -and $cpuMaxClockSpeed -le 1000000)
{
$cpuMaxClockSpeed = $cpuMaxClockSpeed / 1000
$cpuMaxClockSpeed = [System.Math]::Round($cpuMaxClockSpeed, 2)
$actualMaxClockSpeed = $cpuMaxClockSpeed.ToString() + " GHz"
}
elseif($cpuMaxClockSpeed -gt 1000000)
{
$cpuMaxClockSpeed = $cpuMaxClockSpeed / 1000000
$cpuMaxClockSpeed = [System.Math]::Round($cpuMaxClockSpeed, 2)
$actualMaxClockSpeed = $cpuMaxClockSpeed.ToString() + " THz"
}
}
else
{
$actualMaxClockSpeed = "Not Available"
}

$cpuModel = formatString($dcimProcInst.Model)
$cpuManufacturer = formatString($dcimProcInst.Manufacturer)
$cpuNumberOfProcessorCores = $dcimProcInst.NumberOfProcessorCores

$cpuCharacteristics = $dcimProcInst.Characteristics
$actualCharacterstics = $characteristicsMap.Item("$cpuCharacteristics")
if($actualCharacterstics -eq $null)
{
$actualCharacterstics = "Not Available"
}

[int]$cpuHyperThreadingEnabled = $dcimProcInst.HyperThreadingEnabled
$actualHyperThreadingEnabled = $CapableEnabledMap.Item($cpuHyperThreadingEnabled)
if($actualHyperThreadingEnabled -eq $null)
{
$actualHyperThreadingEnabled = "Not Available"
}

[int]$cpuHyperThreadingCapable = $dcimProcInst.HyperThreadingCapable
$actuaHyperThreadingCapable = $CapableEnabledMap.Item($cpuHyperThreadingCapable)
if($actuaHyperThreadingCapable -eq $null)
{
$actuaHyperThreadingCapable = "Not Available"
}

[int]$cpuVirtualizationTechnologyEnabled = $dcimProcInst.VirtualizationTechnologyEnabled
$actualVirtualizationTechnologyEnabled = $CapableEnabledMap.Item($cpuVirtualizationTechnologyEnabled)
if($actualVirtualizationTechnologyEnabled -eq $null)
{
$actualVirtualizationTechnologyEnabled = "Not Available"
}

[int]$cpuVirtualizationTechnologyCapable = $dcimProcInst.VirtualizationTechnologyCapable
$actualVirtualizationTechnologyCapable = $CapableEnabledMap.Item($cpuVirtualizationTechnologyCapable)
if($actualVirtualizationTechnologyCapable -eq $null)
{
$actualVirtualizationTechnologyCapable = "Not Available"
}

[int]$cpuExecuteDisabledEnabled = $dcimProcInst.ExecuteDisabledEnabled
$actualExecuteDisabledEnabled = $CapableEnabledMap.Item($cpuExecuteDisabledEnabled)
if($actualExecuteDisabledEnabled -eq $null)
{
$actualExecuteDisabledEnabled = "Not Available"
}

[int]$cpuExecuteDisabledCapable = $dcimProcInst.ExecuteDisabledCapable
$actualExecuteDisabledCapable = $CapableEnabledMap.Item($cpuExecuteDisabledCapable)
if($actualExecuteDisabledCapable -eq $null)
{
$actualExecuteDisabledCapable = "Not Available"
}

[int]$cpuTurboModeEnabled = $dcimProcInst.TurboModeEnabled
$actualTurboModeEnabled = $CapableEnabledMap.Item($cpuTurboModeEnabled)
if($actualTurboModeEnabled -eq $null)
{
$actualTurboModeEnabled = "Not Available"
}

[int]$cpuTurboModeCapable = $dcimProcInst.TurboModeCapable
$actualTurboModeCapable = $CapableEnabledMap.Item($cpuTurboModeCapable)
if($actualTurboModeCapable -eq $null)
{
$actualTurboModeCapable = "Not Available"
}

psDebugLog -level 1 -message "get-ServerProcessorInstanceDiscovery is Started "
$procUnitInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']$")
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Processors']/ID$", "Processor Group")
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/DeviceID$", $procDeviceID)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/Family$", $actualCPUFamily)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/MaxClockSpeed$", $actualMaxClockSpeed)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/Model$", $cpuModel)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/Manufacturer$", $cpuManufacturer)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/NumberOfProcessorCores$", $cpuNumberOfProcessorCores)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/Characteristics$", $actualCharacterstics)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/HyperThreadingEnabled$", $actualHyperThreadingEnabled)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/HyperThreadingCapable$", $actuaHyperThreadingCapable)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/VirtualizationTechnologyEnabled$", $actualVirtualizationTechnologyEnabled)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/VirtualizationTechnologyCapable$", $actualVirtualizationTechnologyCapable)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/XDEnabled$", $actualExecuteDisabledEnabled)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/XDCapable$", $actualExecuteDisabledCapable)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/TurboModeEnabled$", $actualTurboModeEnabled)
$procUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ProcUnit']/TurboModeCapable$", $actualTurboModeCapable)
$procUnitInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $procDeviceID)
$discoveryData.AddInstance($procUnitInst)
psDebugLog -level 1 -message "get-ServerProcessorInstanceDiscovery is Ended "
}
$memTypeMap = @{1 = "Other";
2 = "Unknown";
3 = "DRAM";
4 = "EDRAM";
5 = "VRAM";
6 = "SRAM";
7 = "RAM";
8 = "ROM";
9 = "FLASH";
10 = "EEPROM";
11 = "FEPROM";
12 = "EPROM";
13 = "CDRAM";
14 = "3DRAM";
15 = "SDRAM";
16 = "SGRAM";
17 = "RDRAM";
18 = "DDR";
19 = "DDR-2";
20 = "DDR-2-FB-DIMM";
24 = "DDR-3";
25 = "FBD2";
26 = "DDR4"}

$memRankMap = @{0 = "Unknown";
1 = "Single Rank";
2 = "Double Rank";
4 = "Quad Rank"}

$memTechnologyMap = @{0 = "Information Not Available";
1 = "Other";
2 = "Unknown";
3 = "DRAM";
4 = "NVDIMM-N";
5 = "NVDIMM-F";
6 = "NVDIMM-P";
7 = "Intel persistent";}

$memSystemEraseCapabilityMap = @{0 = "Not Supported";
1 = "Supported";}

function get-ServerMemoryDiscovery
{
psDebugLog -level 1 -message "get-ServerMemoryDiscovery is Started "
$meminst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Memory']$")
$meminst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$meminst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Memory']/ID$", "Memory Group")
$meminst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Memory Group")
$discoveryData.AddInstance($meminst)
foreach($dcimMemInst in $dcimMemInstArray)
{
get-ServerMemIntsDiscovery -dcimMemInst $dcimMemInst
}
psDebugLog -level 1 -message "get-ServerMemoryDiscovery is Ended "
}

function checkInstances
{
param($keyvalue, $dcimArray, $memberTag)
$retBool = $false
$currentVdArray = @()
if(($dcimArray -ne $null) -and ($dcimArray.count -gt 0))
{
foreach($dciminst in $dcimArray)
{
if(($dciminst.$memberTag).contains($keyvalue))
{
$currentVdArray += $dciminst
}
}
}
if($currentVdArray.count -gt 0)
{
$retBool = $true
}
return $retBool
}

function add-ParentStorageTree
{
param($MPKeyName, $MPKeyValue, $ParentKeyName, $ParentKeyValue, $ParentKeyId, $classInstance)
$log = 2
[Array]$matchedArray = $storageTreeMap.Item($ParentKeyId)
psDebugLog -level $log -message ("`n ENtered ADPST")
if($matchedArray.count -gt 0)
{
$rkey = $matchedArray[0]
#$classInstance.AddProperty($matchedArray[1], $matchedArray[2])
#psDebugLog -level 2 -message ("add-PST Adding First Parent with NAME KEY $($matchedArray[2])")
while($rkey -gt 0)
{
[Array]$parentArray = $storageTreeMap.Item($rkey)
$classInstance.AddProperty($parentArray[1], $parentArray[2])
psDebugLog -level $log -message ("Adding hosting Parent KEY NAME $($parentArray[1]) KEY $($parentArray[2])")
[int]$rkey = $parentArray[0]
}
}
#adding the immediate parent
if($ParentKeyName -ne $null)
{
#if condition to avoid first time key addition
$classInstance.AddProperty($ParentKeyName, $ParentKeyValue)
psDebugLog -level $log -message ("Adding IMMEDIATE PARENT KEY NAME $ParentKeyName Parent $parentkeyValue")
$classInstance.AddProperty($MPKeyName, $MPKeyValue)
psDebugLog -level $log -message ("Adding KEY NAME $MPKeyName KEY $MPKeyValue")
}
[Array]$tmpArray = @($ParentKeyId, $MPKeyName, $MPKeyValue)

$script:storageTreeIditer++
$storageTreeMap.Add($script:storageTreeIditer, [Array]$tmpArray)
psDebugLog -level $log -message ("KEY ID returning NAME $MPKeyName KEY $MPKeyValue")
return $script:storageTreeIditer
}

function get-mapping
{
#value datatype be byte
param($value, $mapTable)
if($value -eq $null)
{
return "Not Available"
}
$ret = $mapTable.item([int]$value)
if($ret -eq $null)
{
return "Not Available"
}
return $ret
}

function To-calculate-unit
{
[cmdletbinding(SupportsShouldProcess)]
Param(
[ValidateNotNullorEmpty()][parameter(Mandatory=$true)]
$inputvalue
)
[float]$memattributeSize = $inputvalue
if($memattributeSize -le 1024)
{
$actualmemattributeSize = $memattributeSize.ToString() + " MB"

}
elseif($memattributeSize -gt 1024 -and $memattributeSize -le 1048576)
{
$memattributeSize = $memattributeSize / 1024
$memattributeSize = [System.Math]::Round($memattributeSize, 2)
$actualmemattributeSize = $memattributeSize.ToString() + " GB"

}
elseif($memattributeSize -gt 1048576)
{
$memattributeSize = $memattributeSize / 1048576
$memattributeSize = [System.Math]::Round($memattributeSize, 2)
$actualmemattributeSize = $memattributeSize.ToString() + " TB"

}
return $actualmemattributeSize
}

function get-ServerMemIntsDiscovery
{
param($dcimMemInst)
$memInstanceID = formatString($dcimMemInst.InstanceID)
[int]$memoryType = $dcimMemInst.MemoryType
$memActualType = $memTypeMap.Item( $memoryType )
if($memActualType -eq $null)
{
$memActualType = "Not Available"
}

[float]$memCapacity = $dcimMemInst.Size
if($memCapacity -ne "Not Available")
{
if($memCapacity -le 1024)
{
$actualmemCapacity = $memCapacity.ToString() + " MB"
}
elseif($memCapacity -gt 1024 -and $memCapacity -le 1048576)
{
$memCapacity = $memCapacity / 1024
$memCapacity = [System.Math]::Round($memCapacity, 2)
$actualmemCapacity= $memCapacity.ToString() + " GB"
}
elseif($memCapacity -gt 1048576)
{
$memCapacity = $memCapacity / 1048576
$memCapacity = [System.Math]::Round($memCapacity, 2)
$actualmemCapacity = $memCapacity.ToString() + " TB"
}
}
else
{
$actualmemCapacity = "Not Available"
}
psDebugLog -level 1 -message ("Mem Capacity "+$actualmemCapacity)
$memSpeed = $dcimMemInst.Speed
if($memSpeed -ne "Not Available")
{
if($memSpeed -le 1000)
{
$actualmemSpeed = $memSpeed.ToString() + " MHz"
}
elseif($memSpeed -gt 1000 -and $memSpeed -le 1000000)
{
$memSpeed = $memSpeed / 1000
$memSpeed = [System.Math]::Round($memSpeed, 2)
$actualmemSpeed= $memSpeed.ToString() + " GHz"
}
elseif($memSpeed -gt 1000000)
{
$memSpeed = $memSpeed / 1000000
$memSpeed = [System.Math]::Round($memSpeed, 2)
$actualmemSpeed = $memSpeed.ToString() + " THz"
}
}
else
{
$actualmemSpeed = "Not Available"
}
psDebugLog -level 1 -message ("Mem Speed "+$actualmemSpeed)

#cacheSize
$memCacheSize = $dcimMemInst.CacheSize
if([string]::IsNullOrEmpty($memCacheSize) -or [string]::IsNullOrWhiteSpace($memCacheSize))
{
$actualmemCacheSize = "Not Available"
}
else
{
if($memCacheSize -ne "Not Available")
{
$actualmemCacheSize = To-calculate-unit -inputvalue $memCacheSize
}
else
{
$actualmemCacheSize = "Not Available"
}
}
psDebugLog -level 1 -message ("Mem CacheSize "+$actualmemCacheSize)

#memoryTechnology
[int]$memMemoryTechnology = $dcimMemInst.MemoryTechnology
$memActualTechnology = $memTechnologyMap.Item($memMemoryTechnology )
if([string]::IsNullOrEmpty($memActualTechnology) -or [string]::IsNullOrWhiteSpace($memActualTechnology))
{
$memActualTechnology = "Not Available"
}
psDebugLog -level 1 -message ("Mem Technology " + $memActualTechnology)

#NonVolatileSize
$memNonVolatileSize = $dcimMemInst.NonVolatileSize
if([string]::IsNullOrEmpty($memNonVolatileSize) -or [string]::IsNullOrWhiteSpace($memNonVolatileSize))
{
$actualmemNonVolatileSize = "Not Available"
}
else
{
if($memNonVolatileSize -ne "Not Available")
{
$actualmemNonVolatileSize = To-calculate-unit -inputvalue $memNonVolatileSize
}
else
{
$actualmemNonVolatileSize = "Not Available"
}
}
psDebugLog -level 1 -message ("Mem NonVolatileSize " + $actualmemNonVolatileSize)

#VolatileSize
$memVolatileSize = $dcimMemInst.VolatileSize
if([string]::IsNullOrEmpty($memVolatileSize) -or [string]::IsNullOrWhiteSpace($memVolatileSize))
{
$actualmemVolatileSize = "Not Available"

}
else
{
if($memVolatileSize -ne "Not Available")
{
$actualmemVolatileSize = To-calculate-unit -inputvalue $memVolatileSize
}
else
{
$actualmemVolatileSize = "Not Available"
}
}
psDebugLog -level 1 -message ("Mem VolatileSize "+$actualmemVolatileSize)

#RemainingRatedWriteEndurance
$memRemainingWriteEndurance = $dcimMemInst.RemainingRatedWriteEndurance
if([string]::IsNullOrEmpty($memRemainingWriteEndurance) -or [string]::IsNullOrWhiteSpace($memRemainingWriteEndurance))
{
$memRemainingWriteEndurance = "Not Available"
}
psDebugLog -level 1 -message ("Mem RemainingRatedWriteEndurance "+$memRemainingWriteEndurance)

#SystemEraseCapability
[int]$memSystemEraseCapability = $dcimMemInst.SystemEraseCapability
$memActualEraseCapability = $memSystemEraseCapabilityMap.Item($memSystemEraseCapability)
if(($memActualEraseCapability -eq $null) -or($memActualEraseCapability -eq "") -or($memActualEraseCapability -eq " "))
{
$memActualEraseCapability = "Not Available"
}
psDebugLog -level 1 -message ("Mem SystemEraseCapability "+$memActualEraseCapability)

$memModel = formatString($dcimMemInst.Model)
$memManufacturer = formatString($dcimMemInst.Manufacturer)
$memSerialNumber = formatString($dcimMemInst.SerialNumber)
$memPartNumber = formatString($dcimMemInst.PartNumber)
$memBankLabel = formatString($dcimMemInst.BankLabel)
$memManufactureDate = formatString($dcimMemInst.ManufactureDate)


[int]$memRank = $dcimMemInst.Rank
$memActualRank = $memRankMap.Item( $memRank )
if($memActualRank -eq $null)
{
$memActualRank = "Not Available"
}

psDebugLog -level 1 -message "get-ServerMemoryInstanceDiscovery is Started "
$memUnitInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']$")
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Memory']/ID$", "Memory Group")
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/ID$", $memInstanceID)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/MemoryType$", $memActualType)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/Capacity$", $actualmemCapacity)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/Speed$", $actualmemSpeed)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/Model$", $memModel)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/Manufacturer$", $memManufacturer)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/SerialNumber$", $memSerialNumber)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/PartNumber$", $memPartNumber)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/BankLabel$", $memBankLabel)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/ManufactureDate$", $memManufactureDate)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/CacheSize$", $actualmemCacheSize)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/MemoryTechnology$", $memActualTechnology)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/NonVolatileSize$", $actualmemNonVolatileSize)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/RemainingRatedWriteEndurance$",$memRemainingWriteEndurance)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/SystemEraseCapability$", $memActualEraseCapability)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/VolatileSize$", $actualmemVolatileSize)
$memUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.MemoryUnit']/Rank$", $memActualRank)
$memUnitInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $memInstanceID)
$discoveryData.AddInstance($memUnitInst)
psDebugLog -level 1 -message "get-ServerMemoryInstanceDiscovery is Ended "
}

function get-EnclosureFanSensor
{
param($dcimEnclosureFanSensor ,$parentKeyName ,$parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.Enclosure.FanSensor'
psDebugLog -level 1 -message "Discovery Started for $className for ID $($dcimEnclosureFanSensor.FQDD)"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.FanSensor']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.FanSensor']/ID$"
$keyvalue = $dcimEnclosureFanSensor.FQDD

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", $keyvalue, $false)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className for ID $($dcimEnclosureFanSensor.FQDD)"
}

function get-EnclosureFanSensorGroup
{
param($enclosureKey ,$parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.Enclosure.FanSensorGroup'
psDebugLog -level 1 -message "Discovery Started for $className"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.FanSensorGroup']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.FanSensorGroup']/ID$"
$keyvalue = "Fan Sensor Group "+$enclosureKey

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", "Fan Sensors", $false)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className"
if(($dcimEnclosureFanSensorArray -ne $null) -and ($dcimEnclosureFanSensorArray.count -gt 0))
{
foreach($dcimEnclosureFanSensor in $dcimEnclosureFanSensorArray)
{
if(($dcimEnclosureFanSensor.FQDD).contains($enclosureKey))
{
get-EnclosureFanSensor -dcimEnclosureFanSensor $dcimEnclosureFanSensor -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}
}
}
}

function get-EnclosureTempSensor
{
param($dcimEnclosureTempSensor ,$parentKeyName ,$parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.Enclosure.TempSensor'
psDebugLog -level 1 -message "Discovery Started for $className for ID $($dcimEnclosureTempSensor.FQDD)"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.TempSensor']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.TempSensor']/ID$"
$keyvalue = $dcimEnclosureTempSensor.FQDD

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", $keyvalue, $false)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className for ID $($dcimEnclosureTempSensor.FQDD)"
}

function get-EnclosureTempSensorGroup
{
param($enclosureKey ,$parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.Enclosure.TempSensorGroup'
psDebugLog -level 1 -message "Discovery Started for $className"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.TempSensorGroup']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.TempSensorGroup']/ID$"
$keyvalue = "Temperature Sensor Group "+$enclosureKey

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", "Temperature Sensors", $false)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className"
if(($dcimEnclosureTempSensorArray -ne $null) -and ($dcimEnclosureTempSensorArray.count -gt 0))
{
foreach($dcimEnclosureTempSensor in $dcimEnclosureTempSensorArray)
{
if(($dcimEnclosureTempSensor.FQDD).contains($enclosureKey))
{
get-EnclosureTempSensor -dcimEnclosureTempSensor $dcimEnclosureTempSensor -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}
}
}
}

function get-EnclosureSensor
{
param($parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.Enclosure.Sensor'
psDebugLog -level 1 -message "Discovery Started for $className"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.Sensor']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.Sensor']/ID$"
$keyvalue = "Enclosure Sensor "+$parentKeyValue

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", "Sensors", $false)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className"

$fansensorChk = checkInstances -keyvalue $parentKeyValue -dcimArray $dcimEnclosureFanSensorArray -memberTag "FQDD"
$tempsensorChk = checkInstances -keyvalue $parentKeyValue -dcimArray $dcimEnclosureTempSensorArray -memberTag "FQDD"
if($tempsensorChk)
{
get-EnclosureTempSensorGroup -enclosureKey $parentKeyValue -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}

if($fansensorChk)
{
get-EnclosureFanSensorGroup -enclosureKey $parentKeyValue -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}

}

function get-InternalPhysicalDisk
{
param($dcimPhysicalDisk, $parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk'
psDebugLog -level 1 -message "Discovery Started for $className for ID $($dcimPhysicalDisk.FQDD)"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/ID$"
$keyvalue = $dcimPhysicalDisk.FQDD

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$busProtocol = get-mapping -value $dcimPhysicalDisk.busProtocol -mapTable @{0="Unknown";1="SCSI";2="PATA";3="FIBRE";4="USB";5="SATA";6="SAS";7="PCIe"}
$Size = convertMemorySize -memSizeStr $dcimPhysicalDisk.SizeInBytes -unit 0
$hotSpare = get-mapping -value $dcimPhysicalDisk.HotSpareStatus -mapTable @{0="No";1="Dedicated";2="Global"}
$NegSpeedRaidEnum = $dcimRAIDEnumeration | where{$_.FQDD -eq $dcimPhysicalDisk.FQDD -and $_.AttributeName -eq "RAIDNegotiatedSpeed"}
$NegotiatedSpeedArray = $NegSpeedRaidEnum.CurrentValue
$NegotiatedSpeed = (($NegotiatedSpeedArray[0]).replace("_GBS"," Gbps")).replace("_",".")
$capableSpeed = get-mapping -value $dcimPhysicalDisk.MaxCapableSpeed -mapTable @{0="Unknown";1="1.5 Gbps";2="3 Gbps";3="6 Gbps";4="12 Gbps"}
$mediaType = get-mapping -value $dcimPhysicalDisk.MediaType -mapTable @{0="Magnetic Drive";1="Solid State Drive"}
$formFactor = get-mapping -value $dcimPhysicalDisk.DriveFormFactor -mapTable @{0="Unknown";1="1.8 inch";2="2.5 inch";3="3.5 inch";4="2.5 inch Add-in card"}
$SecurityState = get-mapping -value $dcimPhysicalDisk.SecurityState -mapTable @{0="Not Capable";1="Secured";2="Locked";3="Foreign";4="Encryption Capable";5="Unknown"}

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", $keyvalue, $false);
"Type" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/Type$", $busProtocol, $false);
"Capacity" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/Capacity$", $Size, $false);
"Hot Spare" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/HotSpare$", $hotSpare, $false);
"Manufacturer" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/VendorID$", $dcimPhysicalDisk.Manufacturer, $true);
"Product ID" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/ProductID$", $dcimPhysicalDisk.Model, $true);
"Revision" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/Revision$", $dcimPhysicalDisk.Revision, $true);
"Serial Number" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/SerialNumber$", $dcimPhysicalDisk.SerialNumber, $true);
"Negotiated Speed" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/NegotiatedSpeed$", $NegotiatedSpeed, $true);
"Capable Speed" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/CapableSpeed$", $capableSpeed, $false);
"Manufacture Day" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/ManufactureDay$", $dcimPhysicalDisk.ManufacturingDay, $true);
"Manufacture Week" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/ManufactureWeek$", $dcimPhysicalDisk.ManufacturingWeek, $true);
"Manufacture Year" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/ManufactureYear$", $dcimPhysicalDisk.ManufacturingYear, $true);
"SAS Address" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/SASAddress$", $dcimPhysicalDisk.SASAddress, $true);
"Media Type" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/MediaType$", $mediaType, $false);
"Drive Form Factor" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/DriveFormFactor$", $formFactor , $false);
"Security State" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/SecurityState$", $SecurityState, $false);
"Slot Number" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/SlotNumber$", $dcimPhysicalDisk.Slot, $true);
"Part Number" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/PartNumber$", $dcimPhysicalDisk.PPID, $true);
"Supported Encryption Types" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.InternalPhysicalDisk']/SupportedEncryptionTypes$", $dcimPhysicalDisk.SupportedEncryptionTypes, $true)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className for ID $($dcimPhysicalDisk.FQDD)"
}

function get-EnclosureInternalPhysicalDiskGroup
{
param($parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.Enclosure.InternalPhysicalDiskGroup'
psDebugLog -level 1 -message "Discovery Started for $className"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.InternalPhysicalDiskGroup']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.InternalPhysicalDiskGroup']/Number$"
$keyvalue = $parentKeyValue

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", "Enclosure Physical Disk Group", $false)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className"

if(($dcimPhysicalDiskViewArray -ne $null) -and ($dcimPhysicalDiskViewArray.count -gt 0))
{
foreach($dcimPhysicalDisk in $dcimPhysicalDiskViewArray)
{
if(($dcimPhysicalDisk.InstanceID).contains($keyvalue))
{
get-InternalPhysicalDisk -dcimPhysicalDisk $dcimPhysicalDisk -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}
}
}
}

function get-ExternalPhysicalDisk
{
param($dcimPhysicalDisk, $parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk'
psDebugLog -level 1 -message "Discovery Started for $className for ID $($dcimPhysicalDisk.FQDD)"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/ID$"
$keyvalue = $dcimPhysicalDisk.FQDD

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$busProtocol = get-mapping -value $dcimPhysicalDisk.busProtocol -mapTable @{0="Unknown";1="SCSI";2="PATA";3="FIBRE";4="USB";5="SATA";6="SAS";7="PCIe"}
$Size = convertMemorySize -memSizeStr $dcimPhysicalDisk.SizeInBytes -unit 0
$hotSpare = get-mapping -value $dcimPhysicalDisk.HotSpareStatus -mapTable @{0="No";1="Dedicated";2="Global"}
$NegSpeedRaidEnum = $dcimRAIDEnumeration | where{$_.FQDD -eq $dcimPhysicalDisk.FQDD -and $_.AttributeName -eq "RAIDNegotiatedSpeed"}
$NegotiatedSpeedArray = $NegSpeedRaidEnum.CurrentValue
$NegotiatedSpeed = (($NegotiatedSpeedArray[0]).replace("_GBS"," Gbps")).replace("_",".")
$capableSpeed = get-mapping -value $dcimPhysicalDisk.MaxCapableSpeed -mapTable @{0="Unknown";1="1.5 Gbps";2="3 Gbps";3="6 Gbps";4="12 Gbps"}
$mediaType = get-mapping -value $dcimPhysicalDisk.MediaType -mapTable @{0="Magnetic Drive";1="Solid State Drive"}
$formFactor = get-mapping -value $dcimPhysicalDisk.DriveFormFactor -mapTable @{0="Unknown";1="1.8 inch";2="2.5 inch";3="3.5 inch";4="2.5 inch Add-in card"}
$SecurityState = get-mapping -value $dcimPhysicalDisk.SecurityState -mapTable @{0="Not Capable";1="Secured";2="Locked";3="Foreign";4="Encryption Capable";5="Unknown"}

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", $keyvalue, $false);
"Type" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/Type$", $busProtocol, $false);
"Capacity" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/Capacity$", $Size, $false);
"Hot Spare" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/HotSpare$", $hotSpare, $false);
"Manufacturer" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/VendorID$", $dcimPhysicalDisk.Manufacturer, $true);
"Product ID" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/ProductID$", $dcimPhysicalDisk.Model, $true);
"Revision" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/Revision$", $dcimPhysicalDisk.Revision, $true);
"Serial Number" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/SerialNumber$", $dcimPhysicalDisk.SerialNumber, $true);
"Negotiated Speed" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/NegotiatedSpeed$", $NegotiatedSpeed, $true);
"Capable Speed" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/CapableSpeed$", $capableSpeed, $false);
"Manufacture Day" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/ManufactureDay$", $dcimPhysicalDisk.ManufacturingDay, $true);
"Manufacture Week" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/ManufactureWeek$", $dcimPhysicalDisk.ManufacturingWeek, $true);
"Manufacture Year" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/ManufactureYear$", $dcimPhysicalDisk.ManufacturingYear, $true);
"SAS Address" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/SASAddress$", $dcimPhysicalDisk.SASAddress, $true);
"Media Type" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/MediaType$", $mediaType, $false);
"Drive Form Factor" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/DriveFormFactor$", $formFactor , $false);
"Security State" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/SecurityState$", $SecurityState, $false);
"Slot Number" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/SlotNumber$", $dcimPhysicalDisk.Slot, $true);
"Part Number" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/PartNumber$", $dcimPhysicalDisk.PPID, $true);
"Supported Encryption Types" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.ExternalPhysicalDisk']/SupportedEncryptionTypes$", $dcimPhysicalDisk.SupportedEncryptionTypes, $true)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className for ID $($dcimPhysicalDisk.FQDD)"
}

function get-EnclosureExternalPhysicalDiskGroup
{
param($parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.Enclosure.ExternalPhysicalDiskGroup'
psDebugLog -level 1 -message "Discovery Started for $className"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.ExternalPhysicalDiskGroup']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.ExternalPhysicalDiskGroup']/Number$"
$keyvalue = $parentKeyValue

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", "Enclosure Physical Disk Group", $false);
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className"

if(($dcimPhysicalDiskViewArray -ne $null) -and ($dcimPhysicalDiskViewArray.count -gt 0))
{
foreach($dcimPhysicalDisk in $dcimPhysicalDiskViewArray)
{
if(($dcimPhysicalDisk.InstanceID).contains($keyvalue))
{
get-ExternalPhysicalDisk -dcimPhysicalDisk $dcimPhysicalDisk -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}
}
}
}

function get-DirectAttachedPhysicalDisk
{
param($dcimPhysicalDisk, $parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk'
psDebugLog -level 1 -message "Discovery Started for $className for ID $($dcimPhysicalDisk.FQDD)"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/ID$"
$keyvalue = $dcimPhysicalDisk.FQDD

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$busProtocol = get-mapping -value $dcimPhysicalDisk.busProtocol -mapTable @{0="Unknown";1="SCSI";2="PATA";3="FIBRE";4="USB";5="SATA";6="SAS";7="PCIe"}
$Size = convertMemorySize -memSizeStr $dcimPhysicalDisk.SizeInBytes -unit 0
$hotSpare = get-mapping -value $dcimPhysicalDisk.HotSpareStatus -mapTable @{0="No";1="Dedicated";2="Global"}
$NegSpeedRaidEnum = $dcimRAIDEnumeration | where{$_.FQDD -eq $dcimPhysicalDisk.FQDD -and $_.AttributeName -eq "RAIDNegotiatedSpeed"}
$NegotiatedSpeedArray = $NegSpeedRaidEnum.CurrentValue
$NegotiatedSpeed = (($NegotiatedSpeedArray[0]).replace("_GBS"," Gbps")).replace("_",".")
$capableSpeed = get-mapping -value $dcimPhysicalDisk.MaxCapableSpeed -mapTable @{0="Unknown";1="1.5 Gbps";2="3 Gbps";3="6 Gbps";4="12 Gbps"}
$mediaType = get-mapping -value $dcimPhysicalDisk.MediaType -mapTable @{0="Magnetic Drive";1="Solid State Drive"}
$formFactor = get-mapping -value $dcimPhysicalDisk.DriveFormFactor -mapTable @{0="Unknown";1="1.8 inch";2="2.5 inch";3="3.5 inch";4="2.5 inch Add-in card"}
$SecurityState = get-mapping -value $dcimPhysicalDisk.SecurityState -mapTable @{0="Not Capable";1="Secured";2="Locked";3="Foreign";4="Encryption Capable";5="Unknown"}

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", $keyvalue, $false);
"Type" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/Type$", $busProtocol, $false);
"Capacity" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/Capacity$", $Size, $false);
"Hot Spare" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/HotSpare$", $hotSpare, $false);
"Manufacturer" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/VendorID$", $dcimPhysicalDisk.Manufacturer, $true);
"Product ID" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/ProductID$", $dcimPhysicalDisk.Model, $true);
"Revision" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/Revision$", $dcimPhysicalDisk.Revision, $true);
"Serial Number" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/SerialNumber$", $dcimPhysicalDisk.SerialNumber, $true);
"Negotiated Speed" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/NegotiatedSpeed$", $NegotiatedSpeed, $true);
"Capable Speed" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/CapableSpeed$", $capableSpeed, $false);
"Manufacture Day" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/ManufactureDay$", $dcimPhysicalDisk.ManufacturingDay, $true);
"Manufacture Week" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/ManufactureWeek$", $dcimPhysicalDisk.ManufacturingWeek, $true);
"Manufacture Year" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/ManufactureYear$", $dcimPhysicalDisk.ManufacturingYear, $true);
"SAS Address" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/SASAddress$", $dcimPhysicalDisk.SASAddress, $true);
"Media Type" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/MediaType$", $mediaType, $false);
"Drive Form Factor" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/DriveFormFactor$", $formFactor , $false);
"Security State" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/SecurityState$", $SecurityState, $false);
"Slot Number" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/SlotNumber$", $dcimPhysicalDisk.Slot, $true);
"Part Number" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/PartNumber$", $dcimPhysicalDisk.PPID, $true);
"Supported Encryption Types" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.DirectAttachedPhysicalDisk']/SupportedEncryptionTypes$", $dcimPhysicalDisk.SupportedEncryptionTypes, $true)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className for ID $($dcimPhysicalDisk.FQDD)"
}

function get-EnclosurePSU
{
param($dcimEnclosurePSU, $parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.Enclosure.PowerSupply'
psDebugLog -level 1 -message "Discovery Started for $className for ID $($dcimEnclosurePSU.FQDD)"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.PowerSupply']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.PowerSupply']/ID$"
$keyvalue = $dcimEnclosurePSU.FQDD

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", $keyvalue, $false);
"Part Number" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.PowerSupply']/PartNumber$", $dcimEnclosurePSU.PartNumber, $true)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className for ID $($dcimEnclosurePSU.FQDD)"
}

function get-EnclosurePowerSupplyGroup
{
param($parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.Enclosure.PowerSupplyGroup'
psDebugLog -level 1 -message "Discovery Started for $className"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.PowerSupplyGroup']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.PowerSupplyGroup']/Number$"
$keyvalue = $parentKeyValue

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", "Enclosure Power Supply Group", $false);
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className"

if(($dcimEnclosurePSUViewArray -ne $null) -and ($dcimEnclosurePSUViewArray.count -gt 0))
{
foreach($dcimEnclosurePSU in $dcimEnclosurePSUViewArray)
{
if(($dcimEnclosurePSU.InstanceID).contains($parentKeyValue))
{
get-EnclosurePSU -dcimEnclosurePSU $dcimEnclosurePSU -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}
}
}
}

function get-EnclosureEMM
{
param($dcimEnclosureEMM, $parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.Enclosure.EMM'
psDebugLog -level 1 -message "Discovery Started for $className -- Key -- $($dcimEnclosureEMM.InstanceID)"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.EMM']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.EMM']/ID$"
$keyvalue = $dcimEnclosureEMM.InstanceID

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", $dcimEnclosureEMM.InstanceID, $true);
"Part Number" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.EMM']/PartNumber$", $dcimEnclosureEMM.PartNumber, $true);
"Firmware Version" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure.EMM']/FirmwareVersion$",$dcimEnclosureEMM.Revision, $true)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className"
}

function get-Enclosure
{
param($enclosure, $parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.Enclosure'
psDebugLog -level 1 -message "Discovery Started for $className for KEY $($enclosure.InstanceID)"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure']/ID$"
$keyvalue = $enclosure.InstanceID

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", $keyvalue, $false);
"Connector ID" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure']/Connector$", $enclosure.Connector, $true);
"Firmware Version" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure']/FirmwareVersion$", $enclosure.Version, $true);
"Product Name" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure']/ProductName$", $enclosure.ProductName, $true);
"Service Tag" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure']/ServiceTag$", $enclosure.ServiceTag, $true);
"Asset Tag" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure']/AssetTag$", $enclosure.AssetTag, $true);
"Wired Order" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Enclosure']/WiredOrder$", $enclosure.WiredOrder, $true)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)

if(($dcimEnclosureEMMViewArray -ne $null) -and ($dcimEnclosureEMMViewArray.count -gt 0))
{
psDebugLog -level 1 -message "EnclosureEMM has $($dcimEnclosureEMMViewArray.count)"
foreach($enclosureEMM in $dcimEnclosureEMMViewArray)
{
if(($enclosureEMM.InstanceID).contains($keyvalue))
{
get-EnclosureEMM -dcimEnclosureEMM $enclosureEMM -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}
}
}

if(($dcimPhysicalDiskViewArray -ne $null) -and ($dcimPhysicalDiskViewArray.count -gt 0))
{
psDebugLog -level 1 -message "EnclosurePhysicalDisk has $($dcimPhysicalDiskViewArray.count)"
if(($enclosure.InstanceID).contains("Internal"))
{
psDebugLog -level 1 -message "EnclosurePhysicalDisk is Internal"
$chk = checkInstances -keyvalue $keyvalue -dcimArray $dcimPhysicalDiskViewArray -memberTag "InstanceID"
if($chk)
{
get-EnclosureInternalPhysicalDiskGroup -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyid $keyid
}
}
if(($enclosure.InstanceID).contains("External"))
{
psDebugLog -level 1 -message "EnclosurePhysicalDisk is External"
$chk = checkInstances -keyvalue $keyvalue -dcimArray $dcimPhysicalDiskViewArray -memberTag "InstanceID"
if($chk)
{
get-EnclosureExternalPhysicalDiskGroup -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyid $keyid
}
}
}

if(($dcimEnclosurePSUViewArray -ne $null) -and ($dcimEnclosurePSUViewArray.count -gt 0))
{
psDebugLog -level 1 -message "EnclosurePowerSupply has $($dcimEnclosurePSUViewArray.count)"
$chk = checkInstances -keyvalue $keyvalue -dcimArray $dcimEnclosurePSUViewArray -memberTag "InstanceID"
if($chk)
{
get-EnclosurePowerSupplyGroup -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyid $keyid
}
}


$fansensorChk = checkInstances -keyvalue $keyvalue -dcimArray $dcimEnclosureFanSensorArray -memberTag "FQDD"
$tempsensorChk = checkInstances -keyvalue $keyvalue -dcimArray $dcimEnclosureTempSensorArray -memberTag "FQDD"
if($fansensorChk -or $tempsensorChk)
{
#psDebugLog -level 1 -message "EnclosureSensor has $($dcimEnclosureFanSensorArray.count) Fans and $($dcimEnclosureTempSensorArray.count) Temp Sensors"
get-EnclosureSensor -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyid $keyid
}
psDebugLog -level 1 -message "Discovery Ended for $className for KEY $($enclosure.InstanceID)"
}

function get-enclosureAndCreateConnector
{
param( $parentKeyName, $parentKeyValue, $parentKeyId)
if(($dcimEnclosureViewArray -ne $null) -and ($dcimEnclosureViewArray.count -gt 0))
{
#$ConnectorArray = @()
foreach($enclosure in $dcimEnclosureViewArray)
{
if(($enclosure.InstanceID).contains($parentKeyValue))
{
get-Enclosure -enclosure $enclosure -parentKeyName $parentKeyName -parentKeyValue $parentKeyValue -Parentkeyid $parentKeyId
}
}
#$uniqConnectors = $ConnectorArray | Select-Object -Unique
#foreach($connector in $uniqConnectors)
#{
#get-StorageConnector -connector $connector -parentKeyName $keyname -parentKeyValue $keyvalue
#}
}
}

function get-controllerBattery
{
param($dcimControllerBattery, $parentKeyName, $parentKeyValue, $parentKeyId)

$className = 'Dell.ManagedServer.Storage.Controller.Battery'
psDebugLog -level 1 -message "Discovery Started for $className"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Battery']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Battery']/ID$"
$keyvalue = $dcimControllerBattery.FQDD

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", $keyvalue, $false);
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)

psDebugLog -level 1 -message "Discovery Ended for $className"
}

function get-ControllerBatteryGroup
{
param($Controllerkey, $parentKeyName, $parentKeyValue, $parentKeyId)

$className = 'Dell.ManagedServer.Storage.Controller.BatteryGroup'
psDebugLog -level 1 -message "Discovery Started for $className"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.BatteryGroup']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.BatteryGroup']/ID$"
$keyvalue = "Battery Group"

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", "Battery", $false);
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
#No if because already checked
foreach($controllerBattery in $dcimControllerBatteryArray)
{
if(($controllerBattery.InstanceID).contains($ControllerKey))
{
get-controllerBattery -dcimControllerBattery $controllerBattery -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}
}
psDebugLog -level 1 -message "Discovery Ended for $className"
}

function get-controllerSensorGroup
{
param($parentKeyName, $parentKeyValue, $parentKeyId)

$className = 'Dell.ManagedServer.Storage.Controller.Sensor'
psDebugLog -level 1 -message "Discovery Discovery Started for $classname"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Sensor']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.Sensor']/ID$"
$keyvalue = "Controller Sensor Group"

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -parentKeyId $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", "Controller Sensor", $false);
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)

if(($dcimControllerBatteryArray -ne $null) -and ($dcimControllerBatteryArray.count -gt 0))
{
get-ControllerBatteryGroup -Controllerkey $parentKeyValue -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}
psDebugLog -level 1 -message "Controller Sensor Discovery Ended for $Controller"
}

function get-VirtualDisk
{
param($dcimVirtualDisk, $parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller.VirtualDisk'
psDebugLog -level 1 -message "Discovery Started for $classname for key $($dcimVirtualDisk.Id)"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/ID$"
$keyvalue = $dcimVirtualDisk.FQDD

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$Layout = get-mapping -value $dcimVirtualDisk.RAIDTypes -mapTable @{1="No RAID";2=" RAID 0";4="RAID 1";64="RAID 5";128="RAID 6";2048="RAID 10";8192="RAID 50";16384="RAID 60"}
$Size = convertMemorySize -memSizeStr $dcimVirtualDisk.SizeInBytes -unit 0
$busProtocol = get-mapping -value $dcimVirtualDisk.busProtocol -mapTable @{0="Unknown";1="SCSI";2="PATA";3="FIBRE";4="USB";5="SATA";6="SAS"}
$mediaType = get-mapping -value $dcimVirtualDisk.MediaType -mapTable @{0="Unknown";1="Hard Disk Drive";2="Solid State Drive"}
$readPolicy = get-mapping -value $dcimVirtualDisk.ReadCachePolicy -mapTable @{0="Unknown";16="No Read Ahead";32="Read Ahead";64="Adaptive Read Ahead"}
$writePolicy = get-mapping -value $dcimVirtualDisk.WriteCachePolicy -mapTable @{0="Unknown";1="Write Through";2="Write Back";4="Write Back Force"}
$diskCachePolicy = get-mapping -value $dcimVirtualDisk.DiskCachePolicy -mapTable @{0="Unknown";256="Default";512="Enabled";1024="Disabled"}
$stripeSize = get-mapping -value $dcimVirtualDisk.StripeSize -mapTable @{0="Default";1="512 Bytes";2="1 KB";4="2 KB";8="4 KB";16="8 KB";32="16 KB";64="32 KB";128="64 KB";256="128 KB";512="256 KB";1024="512 KB";2048="1 MB";4096="2 MB";8192="4 MB";16384="8 MB";32768="16 MB"}
$cachecade = get-mapping -value $dcimVirtualDisk.Cachecade -mapTable @{0="Not a Cachecade Virtual Disk";1="Cachecade Virtual Disk"}
$blockSize = convertMemorySize -memSizeStr $dcimVirtualDisk.BlockSizeInBytes -unit 0
$lockStatus = get-mapping -value $dcimVirtualDisk.LockStatus -mapTable @{0="Unlocked";1="Locked"}

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", $dcimVirtualDisk.InstanceID, $true);
"Layout" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/Layout$", $Layout, $false);
"Size" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/Size$", $Size, $false);
"Name" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/Name$", $dcimVirtualDisk.Name, $true);
"Type" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/Type$", $busProtocol, $false);
"Media Type" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/MediaType$", $mediaType, $false);
"Read Policy" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/ReadPolicy$", $readPolicy, $false);
"Write Policy" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/WritePolicy$", $writePolicy, $false);
"Cache Policy" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/CachePolicy$", $diskCachePolicy, $false);
"Stripe Element Size" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/StripeElementSize$", $stripeSize, $false);
"Cachecade" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/Cachecade$", $cachecade, $false);
"Span Depth" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/SpanDepth$", $dcimVirtualDisk.SpanDepth, $true);
"Span Length" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/SpanLength$", $dcimVirtualDisk.SpanLength, $true);
"Block Size" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/BlockSize$", $blockSize, $false);
"Lock Status" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDisk']/LockStatus$", $lockStatus, $false)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className"
}

function get-virtualDiskGroup
{
param($parentKeyName, $parentKeyValue, $parentKeyId)

$className = 'Dell.ManagedServer.Storage.Controller.VirtualDiskGroup'
psDebugLog -level 1 -message "Discovery Started for $classname"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDiskGroup']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller.VirtualDiskGroup']/Number$"
$keyvalue = $parentKeyValue

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", "Virtual Disk Group", $false);
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
#First Create the group and then add instances OR TODO: if no virtual disk dont add groups
if(($dcimVirtualDiskArray -ne $null) -and ($dcimVirtualDiskArray.count -gt 0))
{
foreach($virtualdisk in $dcimVirtualDiskArray)
{
if(($virtualdisk.InstanceID).contains($parentKeyValue))
{
get-VirtualDisk -dcimVirtualDisk $virtualdisk -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}
}
}

psDebugLog -level 1 -message "Discovery Ended for $ClassName"
}

function get-ServerStorageExtenderPhysicalDisk
{
param($dcimBackPlaneDisk, $parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Extender.PhysicalDisk'
psDebugLog -level 1 -message "Discovery Started for $className for ID $($dcimBackPlaneDisk.InstanceID)"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.PhysicalDisk']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.PhysicalDisk']/ID$"
$keyvalue = $dcimBackPlaneDisk.InstanceID

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$busProtocol = get-mapping -value $dcimBackPlaneDisk.busProtocol -mapTable @{0="Unknown";1="SCSI";2="PATA";3="FIBRE";4="USB";5="SATA";6="SAS";7="PCIe"}
$Size = convertMemorySize -memSizeStr $dcimBackPlaneDisk.SizeInBytes -unit 0
#DCIM_PCIeSSDView has attribute MaximumCapablespeed(String) MaxCapableSpeed is in DCIM_PhysicalDiskView(uint32)
#$capableSpeed = get-mapping -value $dcimBackPlaneDisk.MaxCapableSpeed -mapTable @{0="Unknown";1="1.5 Gbps";2="3 Gbps";3="6 Gbps";4="12 Gbps"}
$mediaType = get-mapping -value $dcimBackPlaneDisk.MediaType -mapTable @{0="Magnetic Drive";1="Solid State Drive"}
$formFactor = get-mapping -value $dcimBackPlaneDisk.DriveFormFactor -mapTable @{0="Unknown";1="1.8 inch";2="2.5 inch";3="3.5 inch";4="2.5 inch Add-in card"}

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", $keyvalue, $false);
"Model" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.PhysicalDisk']/Model$", $dcimBackPlaneDisk.Model, $true);
"Size" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.PhysicalDisk']/Size$", $Size, $false);
"Bus Protocol" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.PhysicalDisk']/BusProtocol$", $busProtocol, $false);
"Device Protocol" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.PhysicalDisk']/DeviceProtocol$", $dcimBackPlaneDisk.DeviceProtocol, $true);
"MediaType" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.PhysicalDisk']/MediaType$", $mediaType, $false);
"Manufacturer" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.PhysicalDisk']/Manufacturer$", $dcimBackPlaneDisk.Manufacturer, $true);
"ProductID" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.PhysicalDisk']/ProductID$", $dcimBackPlaneDisk.ProductID, $true);
"SerialNumber" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.PhysicalDisk']/SerialNumber$", $dcimBackPlaneDisk.SerialNumber, $true);
"DriveFormFactor" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.PhysicalDisk']/DriveFormFactor$", $formFactor, $false);
"CapableSpeed" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.PhysicalDisk']/CapableSpeed$", $dcimBackPlaneDisk.MaximumCapableSpeed, $true);
"Firmware Version" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.PhysicalDisk']/FirmwareVersion$", $dcimBackPlaneDisk.Revision, $true)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className for ID $($dcimBackPlaneDisk.InstanceID)"
}

function get-ServerStorageExtenderBackPlane
{
param($dcimBackPlane, $parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Extender.BackPlane'
psDebugLog -level 1 -message "Discovery Started for $className for ID $($dcimBackPlane.InstanceID)"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.BackPlane']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.BackPlane']/ID$"
$keyvalue = $dcimBackPlane.InstanceID

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
#TOCHECK: Product Name has to be Display Name - only DISPLayString change
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", $keyvalue, $false);
"Product Name" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.BackPlane']/DisplayName$", $dcimBackPlane.ProductName, $true);
"Slot Count" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.BackPlane']/SlotCount$", $dcimBackPlane.SlotCount, $true);
"FirmwareVersion" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender.BackPlane']/FirmwareVersion$", $dcimBackPlane.FirmwareVersion, $true)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className for ID $($dcimBackPlane.InstanceID)"

if(($dcimPCIeSSDViewArray -ne $null) -and ($dcimPCIeSSDViewArray.count -gt 0))
{
foreach($dcimBackPlaneDisk in $dcimPCIeSSDViewArray)
{
if(($dcimBackPlaneDisk.InstanceID).contains($keyvalue))
{
get-ServerStorageExtenderPhysicalDisk -dcimBackPlaneDisk $dcimBackPlaneDisk -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}
}
}
}

function get-ServerStorageExtender
{
param($dcimExtender, $parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Extender'
psDebugLog -level 1 -message "Discovery Started for $className for ID $($dcimExtender.InstanceID)"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Extender']/ID$"
$keyvalue = $dcimExtender.InstanceID

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", $keyvalue, $false);
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)
psDebugLog -level 1 -message "Discovery Ended for $className for ID $($dcimExtender.InstanceID)"

if(($dcimPCIeSSDBackPlaneViewArray -ne $null) -and ($dcimPCIeSSDBackPlaneViewArray.count -gt 0))
{
foreach($dcimBackPlane in $dcimPCIeSSDBackPlaneViewArray)
{
if(($dcimBackPlane.InstanceID).contains($keyvalue))
{
get-ServerStorageExtenderBackPlane -dcimBackPlane $dcimBackPlane -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}
}
}
}

function get-ServerStorageController
{
param($dcimControllerInst, $parentKeyName, $parentKeyValue, $parentKeyId)
$className = 'Dell.ManagedServer.Storage.Controller'
psDebugLog -level 1 -message "Discovery Started for $className"
$classInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']$")

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/DeviceID$"
$keyvalue = $dcimControllerInst.FQDD

$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName $parentKeyName -ParentKeyValue $parentKeyValue -Parentkeyid $parentKeyId -ClassInstance $classInst

$CtrlSecurityMap = get-mapping -value $dcimControllerInst.SecurityStatus -mapTable @{0="Encryption Not Capable";1="Encryption Capable";2="Security Key Assigned"}
$CtrlEncryptionModeMap = get-mapping -value $dcimControllerInst.EncryptionMode -mapTable @{0="None";1="Local Key Management";2="Dell Key Management";3="Pending Dell Key Management"}
$CtrlEncryptionCapabilityMap = get-mapping -value $dcimControllerInst.EncryptionCapability -mapTable @{0="None";1="Local Key Management Capable";2="Dell Key Management Capable";3="Local and Dell Key Management Capable"}
$CtrlCachecadeCapabilityMap = get-mapping -value $dcimControllerInst.CachecadeCapability -mapTable @{0="Cachecade Virtual Disk not supported";1="Cachecade Virtual Disk supported"}
$CtrlSlicedVDCapabilityMap = get-mapping -value $dcimControllerInst.SlicedVDCapability -mapTable @{0="Sliced Virtual Disk creation not supported";1="Sliced Virtual Disk creation supported"}
$cacheMemory = convertMemorySize -memSizeStr $dcimControllerInst.CacheSizeInMB -unit 2

$dcimhash = @{
"Display Name" = @("$MPElement[Name='System!System.Entity']/DisplayName$", $keyvalue, $false);
"Slot ID" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/SlotID$", $dcimControllerInst.PCISlot, $true);
"Firmware Version" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/FirmwareVer$", $dcimControllerInst.ControllerFirmwareVersion, $true);
"Driver Version" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/DriverVer$", $dcimControllerInst.DriverVersion, $true);
"PCI Vendor ID" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/PCIVendorID$", $dcimControllerInst.PCIVendorID, $true);
"Device Card Manufacturer" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/DeviceCardManufacturer$", $dcimControllerInst.DeviceCardManufacturer, $true);
"Device Card Slot Type" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/DeviceCardSlotType$", $dcimControllerInst.DeviceCardSlotType, $true);
"Product Name" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/ProductName$", $dcimControllerInst.ProductName, $true);
"SAS Address" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/SASAddress$", $dcimControllerInst.SASAddress, $true);
"Security" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/Security$", $CtrlSecurityMap, $false);
"Encryption Mode" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/EncryptionMode$", $CtrlEncryptionModeMap, $false);
"Encryption Capability" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/EncryptionCapability$", $CtrlEncryptionCapabilityMap, $false);
"Cachecade Capability" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/CachecadeCapability$", $CtrlCachecadeCapabilityMap, $false);
"Sliced VD Capability" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/SlicedVDCapability$", $CtrlSlicedVDCapabilityMap, $false);
"Cache Memory Size" = @("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage.Controller']/CacheMemorySize$", $cacheMemory, $false)
}
addSCOMPropertyFromHash -bundle $dcimhash -classInstance $classInst

$discoveryData.AddInstance($classInst)

if(!([string]::IsNullOrEmpty($dcimControllerInst.FQDD)))
{
$EnclosureChk = checkInstances -keyvalue $keyvalue -dcimArray $dcimEnclosureViewArray -memberTag "InstanceID"
if($EnclosureChk)
{
get-enclosureAndCreateConnector -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}

$VDgroupChk = checkInstances -keyvalue $keyvalue -dcimArray $dcimVirtualDiskArray -memberTag "FQDD"
if($VDgroupChk)
{
psDebugLog -level 1 -message "Creating Virtual Disk Group for Controller ID $keyvalue"
get-virtualDiskGroup -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}

#TOCHECK - Under Controller Sensor only battery group present
$CtrlSensorChk = checkInstances -keyvalue $keyvalue -dcimArray $dcimControllerBatteryArray -memberTag "InstanceID"
if($CtrlSensorChk)
{
get-ControllerSensorGroup -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}

if(($dcimPhysicalDiskViewArray -ne $null) -and ($dcimPhysicalDiskViewArray.count -gt 0))
{
foreach($dcimPhysicalDisk in $dcimPhysicalDiskViewArray)
{
if((($dcimPhysicalDisk.FQDD).contains("Direct")) -and (($dcimPhysicalDisk.FQDD).contains($keyvalue)))
{
get-DirectAttachedPhysicalDisk -dcimPhysicalDisk $dcimPhysicalDisk -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}
}
}
}
psDebugLog -level 1 -message "Storage Controller Discovery is Ended "
}

function get-ServerStorageDiscovery
{
param($systeminstance)
psDebugLog -level 1 -message "get-ServerStorageDiscovery is Started "
$storageinst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage']$")
#$storageinst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
#Adding root of tree hence passing null parent
$rootkeyid = add-ParentStorageTree -MPkeyName "$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$" -MPKeyValue $computerName -ParentKeyName $null -ParentKeyValue $null -Parentkeyid 0 -ClassInstance $storageinst

$keyname = "$MPElement[Name='DellManagedServer!Dell.ManagedServer.Storage']/ID$"
$keyvalue = $serverUID
$keyid = add-ParentStorageTree -MPKeyName $keyname -MPKeyValue $keyvalue -ParentKeyName "$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$" -ParentKeyValue $computerName -Parentkeyid $rootkeyid -ClassInstance $storageinst

$storageinst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$","Storage Group")
$discoveryData.AddInstance($storageinst)
get-relationshipObject("$MPElement[Name='DellManagedServer!DellManagedServer.Contains.Storage']$",$systeminstance, $storageinst)
psDebugLog -level 1 -message "get-ServerStorageDiscovery is Ended "
if(($dcimControllergrpInstArray -ne $null) -and ($dcimControllergrpInstArray.count -gt 0))
{
foreach($controller in $dcimControllergrpInstArray)
{
get-ServerStorageController -dcimControllerInst $controller -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}
}
if(($dcimPCIeSSDExtenderViewArray -ne $null) -and ($dcimPCIeSSDExtenderViewArray.count -gt 0))
{
foreach($dcimExtender in $dcimPCIeSSDExtenderViewArray)
{
get-ServerStorageExtender -dcimExtender $dcimExtender -parentKeyName $keyname -parentKeyValue $keyvalue -parentKeyId $keyid
}
}

}

$licTypeMap = @{1 = "Perpetual";
2 = "Leased";
3 = "Evaluation"
4 = "Site"}

function get-ServerLicenseGroupDiscovery
{
psDebugLog -level 1 -message "get-ServerLicenseGroupDiscovery is Started "
$licensegrpinst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.LicenseGroup']$")

$licensegrpinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$licensegrpinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.LicenseGroup']/ID$", "License Group")
$licensegrpinst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$","iDRAC License Group")
$discoveryData.AddInstance($licensegrpinst)
foreach ($dcimLicenseInst in $dcimLicensegrpInstArray)
{
get-ServerLicenseInstDiscovery -dcimLicenseInst $dcimLicenseInst
}
psDebugLog -level 1 -message "get-ServerLicenseGroupDiscovery is Ended "
}

function get-ServerLicenseInstDiscovery
{
param($dcimLicenseInst)
psDebugLog -level 1 -message "get-ServerLicenseInstDiscovery is Started "
$licenseInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.License']$")
$licenseInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$licenseInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.LicenseGroup']/ID$", "License Group")
$attributeval = formatString($dcimLicenseInst.InstanceID)
$licenseInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.License']/ID$", $attributeval)
[int]$licType = $dcimLicenseInst.LicenseType
$actualLicType = $licTypeMap.Item( $licType )
if($actualLicType -eq $null)
{
$actualLicType = "Not Available"
}
$licenseInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.License']/LicenseType$", $actualLicType)
$licInstallDate = Get-Date -Date ($dcimLicenseInst.LicenseInstallDate).ToUniversalTime() -format s
$licenseInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.License']/LicenseInstallDate$", $licInstallDate)
$licSoldDate = Get-Date -Date ($dcimLicenseInst.LicenseSoldDate).ToUniversalTime() -format s
$licenseInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.License']/LicenseSoldDate$", $licSoldDate)
$attributeval = formatString($dcimLicenseInst.LicenseDescription)
$licenseInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$",$attributeval)
$discoveryData.AddInstance($licenseInst)
}

$psTypeMap = @{ 0 = "AC";
1 = "DC"}

function get-ServerPowerSupplies
{
psDebugLog -level 1 -message "get-ManagedServerPowerSupplies is Started"
$psinstance = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.PowerSupplies']$")

$psinstance.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$psinstance.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.PowerSupplies']/ID$", "Power Supply Group")
$psinstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Power Supply Group")
$discoveryData.AddInstance($psinstance)
foreach($dcimPSInst in $dcimPowerSupplyViewArray)
{
get-ServerPSUnitDiscovery -dcimPSInst $dcimPSInst
}
psDebugLog -level 1 -message "get-ManagedServerPowerSupplies is Ended "
}

function get-ServerPSUnitDiscovery
{
param($dcimPSInst)
$psID = formatString($dcimPSInst.FQDD)
$psDetailedState = formatString($dcimPSInst.DetailedState)
$psTotalOutputPower = $dcimPSInst.TotalOutputPower
$psTotalOutputPower = $psTotalOutputPower.ToString() + " Watts"

[int]$psType = $dcimPSInst.Type
$actualpsType = $psTypeMap.Item($psType)
if($actualpsType -eq $null)
{
$actualpsType = "Not Available"
}

$psModel = formatString($dcimPSInst.Model)
$psManufacturer = formatString($dcimPSInst.Manufacturer)
$psSerialNumber = formatString($dcimPSInst.SerialNumber)
$psPartNumber = formatString($dcimPSInst.PartNumber)
$psFirmwareVersion = formatString($dcimPSInst.FirmwareVersion)

if($psDetailedState -ne "Absent")
{
psDebugLog -level 1 -message "get-ManagedServerPSInstance is Started"
$psUnitInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.PSUnit']$")
$psUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$psUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.PowerSupplies']/ID$", "Power Supply Group")
$psUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.PSUnit']/ID$",$psID)
$psUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.PSUnit']/DetailedState$",$psDetailedState)
$psUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.PSUnit']/TotalOutputPower$",$psTotalOutputPower)
$psUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.PSUnit']/Type$",$actualpsType)
$psUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.PSUnit']/Model$",$psModel)
$psUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.PSUnit']/Manufacturer$",$psManufacturer)
$psUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.PSUnit']/SerialNumber$",$psSerialNumber)
$psUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.PSUnit']/PartNumber$",$psPartNumber)
$psUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.PSUnit']/FirmwareVersion$",$psFirmwareVersion)
$psUnitInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $psID)
$discoveryData.AddInstance($psUnitInst)
psDebugLog -level 1 -message "get-ManagedServerPSInstance is Ended "
}
else
{
psDebugLog -level 1 -message "Power Supply DetailedState is Absent"
}

}
function get-ServerHostNicDiscovery
{
psDebugLog -level 1 -message "get-HostNicDiscovery is Started "
$hostNicInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNICGroup']$")

$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNICGroup']/ID$","HostNIC Group")
$hostNicInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "HostNIC Group")
$discoveryData.AddInstance($hostNicInst)

foreach($hostNic in $dcimHostNicViewArray){
if($hostNic.DeviceFQDD[0] -ne $null){
ServerHostNicUnitDiscovery -hostNic $hostNic
}
}
psDebugLog -level 1 -message "get-HostNicDiscovery is Ended "
}

function get-ServerHostNicUnitDiscovery
{
param($hostNic)
psDebugLog -level 1 -message "get-ServerHostNicUnitDiscovery is Started "
$hostNicInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNIC']$")

$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNICGroup']/ID$","HostNIC Group")
$attributeVal = formatString($hostNic.InstanceID)
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNIC']/InstanceID$", $attributeVal)
$attributeVal = formatString($hostNic.MACAddr)
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNIC']/MACAddress$", $attributeVal)
$attributeVal = formatString($hostNic.DeviceDescription)
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNIC']/DeviceDescription$", $attributeVal)
$attributeVal = formatString($hostNic.IPv4Address)
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNIC']/IPv4Address$", $attributeVal)
$attributeVal = formatString($hostNic.IPv4SubnetMask)
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNIC']/IPv4SubnetMask$", $attributeVal)
$attributeVal = formatString($hostNic.IPv4Gateway)
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNIC']/IPv4Gateway$", $attributeVal)
$attributeVal = formatString($hostNic.IPv6Address)
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNIC']/IPv6Address$", $attributeVal)
$attributeVal = formatString($hostNic.IPv6PrefixLength)
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNIC']/IPv6Prefix$", $attributeVal)
$attributeVal = formatString($hostNic.IPv6Gateway)
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNIC']/IPv6Gateway$", $attributeVal)
$type = formatString($hostNic.Type)
switch ($type){
0 {$attributeVal = "Other"; break}
1 {$attributeVal = "Ethernet"; break}
2 {$attributeVal = "Tokenring"; break}
3 {$attributeVal = "Point-To-Point"; break}
4 {$attributeVal = "Loopback"; break}
5 {$attributeVal = "ATM"; break}
6 {$attributeVal = "IEEE80211 Wireless"; break}
7 {$attributeVal = "Tunnel"; break}
8 {$attributeVal = "IEEE1394 Fireware"; break}
default {$attributeVal = "Not Available"}
}
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNIC']/InterfaceType$", $attributeVal)
$attributeVal = "Not Available"
if($hostNic.DeviceFQDD.count -gt 0){
$attributeVal = formatString($hostNic.DeviceFQDD[0])
}
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNIC']/DeviceFQDD$", $attributeVal)
$attributeVal = formatString($hostNic.Name)
$hostNicInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $attributeVal)
$discoveryData.AddInstance($hostNicInst)
psDebugLog -level 1 -message "get-ServerHostNicUnitDiscovery is Ended "
}

function get-ServerNicDiscovery
{
psDebugLog -level 1 -message "get-NicDiscovery is Started "
$nicInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NICGroup']$")

$nicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$nicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NICGroup']/ID$","NIC Group")
$nicInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Network Interface Card Group")
$discoveryData.AddInstance($nicInst)
foreach($nicUnit in $dcimNicViewArray){
$nicUnitCap = get-NicCapabilitiesProfile -nicUnit $nicUnit
$virtMacAddr = get-NicStringProfile -nicUnit $nicUnit
$hostNic = get-HostNicProfile -nicUnit $nicUnit
get-NetworkInterfaceUnitDiscovery -nicUnit $nicUnit -nicUnitCap $nicUnitCap -virtMacAddr $virtMacAddr -hostNic $hostNic
}
psDebugLog -level 1 -message "get-NicDiscovery is Ended "
}

function get-SwitchConnectionProfile
{
param($fqdd)
psDebugLog -level 1 -message "get-SwitchConnectionProfile (FQDD = $fqdd) "
if(($dcimSwitchConnectionViewArray -ne $null) -and ($dcimSwitchConnectionViewArray.count -gt 0))
{
$result = $dcimSwitchConnectionViewArray | Where-Object {$_.FQDD -eq $fqdd}
}
return $result
}
function Get-SensorObjectByElementName
{
param($elementName)
psDebugLog -level 1 -message "Get-SensorObjectByElementName"
if(($dcimPresenceAndStatusSensorArray -ne $null) -and ($dcimPresenceAndStatusSensorArray.count -gt 0))
{
$result = $dcimPresenceAndStatusSensorArray | Where-Object {$_.ElementName -eq $elementName}
}
return $result
}
function get-NicCapabilitiesProfile
{
param($nicUnit)
foreach($nicUnitCap in $dcimNicCapabilitiesArray){
if($nicUnitCap.FQDD -eq $nicUnit.FQDD){
return $nicUnitCap
}
}
return $null
}

function get-NicStringProfile
{
param($nicUnit)
foreach($nicUnitStr in $dcimNicStringArray){
if(($nicUnitStr.FQDD -eq $nicUnit.FQDD) -and ($nicUnitStr.AttributeName -eq "VirtMacAddr")){
return $nicUnitStr.CurrentValue
}
}
return $null
}

function get-HostNicProfile
{
param($nicUnit)
foreach($hostNic in $dcimHostNicViewArray){
if($hostNic.DeviceFQDD.count -gt 0){
if($hostNic.DeviceFQDD[0] -eq $nicUnit.FQDD){
return $hostNic
}
}
}
return $null
}

function get-NetworkInterfaceUnitDiscovery
{
param($nicUnit, $nicUnitCap, $virtMacAddr, $hostNic)

$systemGeneration = $dcimSystemView.SystemGeneration.trim()
$generation = $systemGeneration.split(" ")[0].replace("G","")
$switchChassisId = "Not Applicable"
$switchPortId = "Not Applicable"

psDebugLog -level 1 -message "get-NetworkInterfaceUnitDiscovery is Started "
$nicUnitInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']$")
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NICGroup']/ID$","NIC Group")
$NICUnitFqdd = formatString($nicUnit.FQDD)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/ID$", $NICUnitFqdd)
$attributeVal = formatString($nicUnit.MediaType)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/MediaType$", $attributeVal)
$mode = formatString($nicUnit.NICMode)
switch ($mode){
0 {$attributeVal = "Unknown"; break}
2 {$attributeVal = "Enabled"; break}
3 {$attributeVal = "Disabled"; break}
default {$attributeVal = "Not Available"}
}
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/NICMode$", $attributeVal)
$attributeVal = formatString($nicUnit.VendorName)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/VendorName$", $attributeVal)
$attributeVal = formatString($nicUnit.ProductName)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/ProductName$", $attributeVal)
$attributeVal = formatString($nicUnit.FamilyVersion)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/FamilyVersion$", $attributeVal)
$pMacAdd = formatString($nicUnit.PermanentMACAddress)
$vMacAdd = formatString($virtMacAddr)
$cMacAdd = formatString($nicUnit.CurrentMACAddress)
if(($vMacAdd -eq "00:00:00:00:00:00") -or ($vMacAdd -eq "FF:FF:FF:FF:FF:FF")){
$vMacAdd = "Not Configured"
}
elseif($pMacAdd -eq $cMacAdd){
$vMacAdd = $pMacAdd
}
else{
if($vMacAdd -eq ""){
$vMacAdd = "Not Available"
}
}
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/PermanentMACAddress$", $pMacAdd)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/VirtualMACAddress$", $vMacAdd)
$attributeVal = formatString($hostNic.IPv4Address)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/IPv4Address$", $attributeVal)
$attributeVal = formatString($hostNic.IPv6Address)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/IPv6Address$", $attributeVal)
$speed = formatString($nicUnit.LinkSpeed)
switch ($speed){
0 {$attributeVal = "Unknown"; break}
1 {$attributeVal = "10 Mbps"; break}
2 {$attributeVal = "100 Mbps"; break}
3 {$attributeVal = "1000 Mbps"; break}
4 {$attributeVal = "2.5 Gbps"; break}
5 {$attributeVal = "10 Gbps"; break}
6 {$attributeVal = "20 Gbps"; break}
7 {$attributeVal = "40 Gbps"; break}
8 {$attributeVal = "100 Gbps"; break}
9 {$attributeVal = "25 Gbps"; break}
10 {$attributeVal = "50 Gbps"; break}
default {$attributeVal = "Not Available"}
}
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/LinkSpeed$", $attributeVal)
$linkduplexmode = formatString($nicUnit.LinkDuplex)
switch ($linkduplexmode){
0 {$attributeVal = "Unknown"; break}
1 {$attributeVal = "Full Duplex"; break}
2 {$attributeVal = "Half Duplex"; break}
default {$attributeVal = "Not Available"}
}
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/LinkDuplexMode$", $attributeVal)
$attributeVal = formatString($nicUnit.PermanentFCOEMACAddress)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/PermanentFCOEMACAddress$", $attributeVal)
$attributeVal = formatString($nicUnit.PermanentiSCSIMACAddress)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/PermanentiSCSIMACAddress$", $attributeVal)
if($nicUnitCap -eq $null)
{
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/SupportedBootProtocol$", "Not Available")
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/NICCapabilities$", "Not Available")
}
else
{
$supportedBootProtocol = ""
if($nicUnitCap.FCoEBootSupport -eq "2")
{
$supportedBootProtocol = "FCoE"
}
if($nicUnitCap.PXEBootSupport -eq "2")
{
if($supportedBootProtocol -eq ""){
$supportedBootProtocol = "PXE"
}
else{
$supportedBootProtocol = $supportedBootProtocol + "," + "PXE"
}
}
if($nicUnitCap.iSCSIBootSupport -eq "2")
{
if($supportedBootProtocol -eq ""){
$supportedBootProtocol = "iSCSI"
}
else{
$supportedBootProtocol = $supportedBootProtocol + "," + "iSCSI"
}
}
$attributeVal = formatString($supportedBootProtocol)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/SupportedBootProtocol$", $attributeVal)

$nICCapabilities = ""
if($nicUnitCap.WOLSupport -eq "2")
{
$nICCapabilities = "WOL"
}
if($nicUnitCap.FlexAddressingSupport -eq "2")
{
if($nICCapabilities -eq ""){
$nICCapabilities = "FlexAddressing"
}
else{
$nICCapabilities = $nICCapabilities + "," + "FlexAddressing"
}
}
if($nicUnitCap.VFSRIOVSupport -eq "2")
{
if($nICCapabilities -eq ""){
$nICCapabilities = "SR-IOV"
}
else{
$nICCapabilities = $nICCapabilities + "," + "SR-IOV"
}
}
if($nicUnitCap.iSCSIOffloadSupport -eq "2")
{
if($nICCapabilities -eq ""){
$nICCapabilities = "iSCSI Offload"
}
else{
$nICCapabilities = $nICCapabilities + "," + " iSCSI Offload"
}
}
if($nicUnitCap.FCoEOffloadSupport -eq "2")
{
if($nICCapabilities -eq ""){
$nICCapabilities = "FCoE Offload"
}
else{
$nICCapabilities = $nICCapabilities + "," + "FCoE Offload"
}
}
if($nicUnitCap.NicPartitioningSupport -eq "2")
{
if($nICCapabilities -eq ""){
$nICCapabilities = "Partitioning"
}
else{
$nICCapabilities = $nICCapabilities + "," + "Partitioning"
}
}
if($nicUnitCap.TCPChimneySupport -eq "2")
{
if($nICCapabilities -eq ""){
$nICCapabilities = "TOE"
}
else{
$nICCapabilities = $nICCapabilities + "," + "TOE"
}
}
if($nicUnitCap.DCBExchangeProtocol -eq "2")
{
if($nICCapabilities -eq ""){
$nICCapabilities = "DCB"
}
else{
$nICCapabilities = $nICCapabilities + "," + "DCB"
}
}
$attributeVal = formatString($nICCapabilities)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/NICCapabilities$", $attributeVal)
}
if ( $generation -gt 13 ){
$switchChassisId = "Not Available"
$switchPortId = "Not Available"
$switchConnectionView = get-SwitchConnectionProfile -fqdd $nicUnit.FQDD
If( $switchConnectionView -ne $null )
{
$switchChassisId = $switchConnectionView.SwitchConnectionID
$switchPortId = $switchConnectionView.SwitchPortConnectionID
}
}
$attributeVal = formatString($switchChassisId)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/SwitchChassisID$", $attributeVal)
$attributeVal = formatString($switchPortId)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/SwitchPortID$", $attributeVal)
$nicUnitInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $NICUnitFqdd)
$discoveryData.AddInstance($nicUnitInst)
psDebugLog -level 1 -message "get-NetworkInterfaceUnitDiscovery is Ended "
}

function get-ServerSDCards
{
psDebugLog -level 1 -message "get-Dell-Managed-Server-SDCards is Started"
$sdcardinstance = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.SDCardGroup']$")

$sdcardinstance.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sdcardinstance.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.SDCardGroup']/ID$", "SD Card Group")
$sdcardinstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "SD Card Group")
$discoveryData.AddInstance($sdcardinstance)

psDebugLog -level 1 -message "SDCardView has $($dcimSdcardViewArray.count) Instances"
foreach($dcimSdcardInst in $dcimSdcardViewArray)
{
psDebugLog -level 1 -message "Starting SD-Card Inventory for $($dcimSdcardInst.FQDD)"
get-ServerSDCardDiscovery -parentkey "SD Card Group" -dcimSdcardInst $dcimSdcardInst
}

psDebugLog -level 1 -message "get-Dell-Managed-Server-SDCards is Ended "
}

function get-ServerSDCardDiscovery
{
param($parentkey, $dcimSdcardInst)

$sdcardID = formatString($dcimSdcardInst.FQDD)
$sdcarddisplayName = formatString($dcimSdcardInst.DeviceDescription)
#Size in MB hence passing 2
$sdcardsize = convertMemorySize -memSizeStr $dcimSdcardInst.Capacity -unit 2
$script:vFlashStorageSize = $script:vFlashStorageSize + $dcimSdcardInst.Capacity
$sdcardwriteProtection = formatString($dcimSdcardInst.WriteProtected)

psDebugLog -level 1 -message "get-ServerSDCardDiscovery is Started"
$Inst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.SDCard']$")
$Inst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$Inst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.SDCardGroup']/ID$", $parentkey)
$Inst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.SDCard']/ID$", $sdcardID)
$Inst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.SDCard']/Size$", $sdcardsize)
$Inst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.SDCard']/WriteProtected$", $sdcardwriteProtection)
$Inst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $sdcarddisplayName)
$discoveryData.AddInstance($Inst)
psDebugLog -level 1 -message "get-ServerSDCardDiscovery is Ended "
}

function get-ServeriDracAndNetworkInterfaceUnitDiscovery
{
psDebugLog -level 1 -message "get-iDracDiscovery is Started "
$systemGeneration = $dcimSystemView.SystemGeneration.trim()
$generation = $systemGeneration.split(" ")[0].replace("G","")
$groupName = "Not Applicable"
$groupStatus = "Not Applicable"
$switchChassisId = "Not Applicable"
$switchPortId = "Not Applicable"
if ( $generation -gt 13 ){
$groupName = "Not Available"
$groupStatus = "Not Available"
$switchChassisId = "Not Available"
$switchPortId = "Not Available"
}

if(($dcimiDracCardStringArray -ne $null) -and ($dcimiDracCardStringArray.count -gt 0))
{
$instanceID = formatString($dcimiDracCardStringArray[0].FQDD)
foreach($iDracNICViewInst in $dcimiDracCardStringArray)
{
if(($iDracNICViewInst.AttributeDisplayName -eq "IPv4 Address") -and ($iDracNICViewInst.FQDD -eq $instanceID) -and ($iDracNICViewInst.GroupID -eq "IPv4.1")){
$ipV4Add = $iDracNICViewInst.CurrentValue
}
if(($iDracNICViewInst.AttributeDisplayName -eq "iDRAC Product Information") -and ($iDracNICViewInst.FQDD -eq $instanceID)){
$productName = $iDracNICViewInst.CurrentValue
}
if(($iDracNICViewInst.AttributeDisplayName -eq "MAC Address") -and ($iDracNICViewInst.FQDD -eq $instanceID)){
$macAdd = $iDracNICViewInst.CurrentValue[-1]
}
if(($iDracNICViewInst.AttributeDisplayName -eq "IPV6 Address 1") -and ($iDracNICViewInst.FQDD -eq $instanceID)){
$ipV6Add = $iDracNICViewInst.CurrentValue
if($ipV6Add -eq "::"){
$ipV6Add = "Not Available"
}
}
if ( $generation -gt 13 )
{
if($iDracNICViewInst.AttributeName -eq "GroupName")
{
$groupName = $iDracNICViewInst.CurrentValue
}
}
}
}
if(($dcimiDracCardEnumerationArray -ne $null) -and ($dcimiDracCardEnumerationArray.count -gt 0)){
foreach($dcimiDracCardEnumeration in $dcimiDracCardEnumerationArray){
if(($dcimiDracCardEnumeration.AttributeDisplayName -eq "NIC Speed") -and ($dcimiDracCardEnumeration.FQDD -eq $instanceID)){
$nicSpeed = $dcimiDracCardEnumeration.CurrentValue
}
if(($dcimiDracCardEnumeration.AttributeDisplayName -eq "NIC Duplex") -and ($dcimiDracCardEnumeration.FQDD -eq $instanceID)){
$nicDuplex = $dcimiDracCardEnumeration.CurrentValue
}
if ( $generation -gt 13 )
{
$idracInstanceID = $dcimiDracCardEnumeration.InstanceID
if($dcimiDracCardEnumeration.AttributeName -eq "Status" -and $idracInstanceID.contains("GroupManager.1#Status") ){
$groupStatus = $dcimiDracCardEnumeration.CurrentValue
}
}
}
}

$idracinst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDRAC']$")
$idracinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$dcimCardViewinstanceID = formatString($dcimiDracCardViewArray[0].FQDD)
$idracinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDRAC']/ID$", $dcimCardViewinstanceID)
$attributeVal = convertMemorySize -memSizeStr $script:vFlashStorageSize -unit 2
$idracinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDRAC']/vFlashStorageSize$", $attributeVal)
$attributeVal = formatString($dcimiDracCardViewArray[0].FirmwareVersion)
$idracinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDRAC']/FirmwareVersion$", $attributeVal)
$attributeVal = formatString($dcimSystemView.LifecycleControllerVersion)
$idracinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDRAC']/LCCVersion$", $attributeVal)
$attributeVal = formatString($dcimiDracCardViewArray[0].Model)
$idracinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDRAC']/Model$", $attributeVal)
$attributeVal = formatString($dcimiDracCardViewArray[0].IPMIVersion)
$idracinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDRAC']/IPMIVersion$", $attributeVal)
$attributeVal = formatString($groupName)
$idracinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDRAC']/GroupName$", $attributeVal)
$attributeVal = formatString($groupStatus)
$idracinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDRAC']/GroupStatus$", $attributeVal)
$idracinst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $dcimCardViewinstanceID)
$discoveryData.AddInstance($idracinst)
psDebugLog -level 1 -message "get-iDracDiscovery is Ended "

if(($dcimiDracCardStringArray -ne $null) -and ($dcimiDracCardStringArray.count -gt 0))
{
psDebugLog -level 1 -message "get-iDracNetworkInterfaceUnitDiscovery is Started "
$idracNicinst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDrac.NetworkInterfaceUnit']$")
$idracNicinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$attributeVal = formatString($dcimiDracCardViewArray[0].FQDD)
$idracNicinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDRAC']/ID$", $attributeVal)
$idracNicinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDrac.NetworkInterfaceUnit']/ID$", $instanceID)
$attributeVal = formatString($productName)
$idracNicinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDrac.NetworkInterfaceUnit']/ProductName$", $attributeVal)
$attributeVal = formatString($macAdd)
$idracNicinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDrac.NetworkInterfaceUnit']/MACAddress$", $attributeVal)
$attributeVal = formatString($ipV4Add)
$idracNicinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDrac.NetworkInterfaceUnit']/IPv4Address$",$attributeVal)
$attributeVal = formatString($ipV6Add)
$idracNicinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDrac.NetworkInterfaceUnit']/IPv6Address$",$attributeVal)
$attributeVal = formatString($nicSpeed)
if($attributeVal -ne "Not Available"){
$attributeVal = $attributeVal + " Mbps"
}
$idracNicinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDrac.NetworkInterfaceUnit']/Speed$",$attributeVal)
$attributeVal = formatString($nicDuplex)
$idracNicinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDrac.NetworkInterfaceUnit']/LinkDuplexMode$",$attributeVal)
if ( $generation -gt 13 )
{
$switchConnectionView = get-SwitchConnectionProfile -fqdd $instanceID
if($switchConnectionView -ne $null)
{
$switchChassisId = $switchConnectionView.SwitchConnectionID
$switchPortId = $switchConnectionView.SwitchPortConnectionID
}
}
$attributeVal = formatString($switchChassisId)
$idracNicinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDrac.NetworkInterfaceUnit']/SwitchChassisID$",$attributeVal)
$attributeVal = formatString($switchPortId)
$idracNicinst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.iDrac.NetworkInterfaceUnit']/SwitchPortID$",$attributeVal)
$idracNicinst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $instanceID)
$discoveryData.AddInstance($idracNicinst)
psDebugLog -level 1 -message "get-iDracNetworkInterfaceUnitDiscovery is Ended "
}
}

function get-ServerBiosDiscovery
{
psDebugLog -level 1 -message "get-BiosDiscovery is Started "
Foreach($softwareIdentityObj in $dcimSoftIdViewArray)
{
#psDebugLog -level 1 -message ("Component Type: " + $softwareIdentityObj.ComponentType + " InstanceID: " + $softwareIdentityObj.InstanceID)
if(($softwareIdentityObj.ComponentType -eq "BIOS") -and ($softwareIdentityObj.InstanceID -match 'INSTALLED#'))
{
$Name = formatString($softwareIdentityObj.FQDD)
$BIOSVersion = formatString($softwareIdentityObj.VersionString)

$SMBIOSPresent = "True"
psDebugLog -level 1 -message ("Name: "+ $softwareIdentityObj.FQDD + ", BIOSVersion: " + $softwareIdentityObj.VersionString +
", SMBIOSPresent: " + $SMBIOSPresent)
}
}
$biosInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.BIOS']$")

$biosInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$biosInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.BIOS']/Name$", $Name)
$biosInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.BIOS']/BIOSVersion$", $BIOSVersion)
$biosInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.BIOS']/SMBIOSPresent$", $SMBIOSPresent)
$attributeVal = formatString($dcimSystemView.Manufacturer)
$biosInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.BIOS']/Manufacturer$", $attributeVal)
$biosInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.BIOS']/SerialNumber$", $serviceTag)
$attributeVal = formatString($dcimSystemView.BIOSReleaseDate)
$biosInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.BIOS']/BIOSReleaseDate$", $attributeVal)
$biosInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $serviceTag)
$discoveryData.AddInstance($biosInst)
psDebugLog -level 1 -message "get-BiosDiscovery is Ended "
}

function get-ServerSensorDiscovery
{
psDebugLog -level 1 -message "get-SensorDiscovery is Started "
$sensorInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']$")

$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']/ID$","SensorsGroup")
$sensorInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Sensors Group")
$discoveryData.AddInstance($sensorInst)
psDebugLog -level 1 -message "get-SensorDiscovery is Ended "

[int[]] $sensorTypeArray = 0,0,0,0,0,0
if($dcimSensorViewArray -ne $null)
{
Foreach($sensorViewObj in $dcimSensorViewArray)
{
$SensorType = $sensorViewObj.SensorType
If($SensorType -eq 16)
{
$sensorTypeArray[0] = 1
}
else
{
$sensorTypeArray[$SensorType] = 1
}
}
}
if($dcimNumSensorViewArray -ne $null)
{
Foreach($sensorViewObj in $dcimNumSensorViewArray)
{
$SensorType = $sensorViewObj.SensorType
if($SensorType -eq 1)
{
if($sensorViewObj.OtherSensorTypeDescription -eq "Battery")
{
$sensorTypeArray[1] = 1
}
}
elseif($SensorType -eq 16)
{
$sensorTypeArray[0] = 1
}
else
{
$sensorTypeArray[$SensorType] = 1
}
}
}
if ($sensorTypeArray[1] -eq 1)
{
psDebugLog -level 1 -message "BatterySensorGroupDiscovery is Started "
$sensorInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.BatterySensorGroup']$")

$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']/ID$","SensorsGroup")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.BatterySensorGroup']/ID$","Battery Sensor Group")
$sensorInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Battery Sensor Group")
$discoveryData.AddInstance($sensorInst)
psDebugLog -level 1 -message "BatterySensorGroupDiscovery is Ended "
}
if ($sensorTypeArray[2] -eq 1)
{
psDebugLog -level 1 -message "TemperatureSensorGroupDiscovery is Started "
$sensorInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.TemperatureSensorGroup']$")

$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']/ID$","SensorsGroup")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.TemperatureSensorGroup']/ID$","Temperature Sensor Group")
$sensorInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Temperature Sensor Group")
$discoveryData.AddInstance($sensorInst)
psDebugLog -level 1 -message "TemperatureSensorGroupDiscovery is Ended "
}
if ($sensorTypeArray[3] -eq 1)
{
psDebugLog -level 1 -message "VoltageSensorGroupDiscovery is Started "
$sensorInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.VoltageSensorGroup']$")

$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']/ID$","SensorsGroup")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.VoltageSensorGroup']/ID$","Voltage Sensor Group")
$sensorInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Voltage Sensor Group")
$discoveryData.AddInstance($sensorInst)
psDebugLog -level 1 -message "VoltageSensorGroupDiscovery is Ended "
}
if ($sensorTypeArray[4] -eq 1)
{
psDebugLog -level 1 -message "CurrentSensorGroupDiscovery is Started "
$sensorInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.CurrentSensorGroup']$")

$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']/ID$","SensorsGroup")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.CurrentSensorGroup']/ID$","Current Sensor Group")
$sensorInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Current Sensor Group")
$discoveryData.AddInstance($sensorInst)
psDebugLog -level 1 -message "CurrentSensorGroupDiscovery is Ended "
}
if ($sensorTypeArray[5] -eq 1)
{
psDebugLog -level 1 -message "FanSensorGroupDiscovery is Started "
$sensorInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.FanSensorGroup']$")

$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']/ID$","SensorsGroup")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.FanSensorGroup']/ID$","Fan Sensor Group")
$sensorInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Fan Sensor Group")
$discoveryData.AddInstance($sensorInst)
psDebugLog -level 1 -message "FanSensorGroupDiscovery is Ended "
}
if ($sensorTypeArray[0] -eq 1)
{
psDebugLog -level 1 -message "IntrusionSensorGroupDiscovery is Started "
$sensorInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.IntrusionSensorGroup']$")

$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']/ID$","SensorsGroup")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.IntrusionSensorGroup']/ID$","Intrusion Sensor Group")
$sensorInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Intrusion Sensor Group")
$discoveryData.AddInstance($sensorInst)
psDebugLog -level 1 -message "IntrusionSensorGroupDiscovery is Ended "
}

if($dcimSensorViewArray -ne $null)
{
Foreach($sensorViewObj in $dcimSensorViewArray)
{
$SensorType = $sensorViewObj.SensorType
$sDeviceID = $sensorViewObj.DeviceID
$sElementName = $sensorViewObj.ElementName
if($SensorType -eq 1 -and $sensorViewObj.OtherSensorTypeDescription -eq "Battery")
{
get-BatterySensorDiscovery -sensorDeviceID $sDeviceID -sensorElementName $sElementName
}
elseif($SensorType -eq 16)
{
get-IntrusionSensorDiscovery -sensorDeviceID $sDeviceID -sensorElementName $sElementName
}
elseif($SensorType -eq 2)
{
get-TemperatureSensorDiscovery -sensorDeviceID $sDeviceID -sensorElementName $sElementName
}
elseif($SensorType -eq 3)
{
get-VoltageSensorDiscovery -sensorDeviceID $sDeviceID -sensorElementName $sElementName
}
elseif($SensorType -eq 4)
{
get-CurrentSensorDiscovery -sensorDeviceID $sDeviceID -sensorElementName $sElementName
}
elseif($SensorType -eq 5)
{
get-FanSensorDiscovery -sensorDeviceID $sDeviceID -sensorElementName $sElementName
}
else{
#Do nothing
}
}
}
if($dcimNumSensorViewArray -ne $null)
{
Foreach($sensorViewObj in $dcimNumSensorViewArray)
{
$SensorType = $sensorViewObj.SensorType
$sDeviceID = $sensorViewObj.DeviceID
$sElementName = $sensorViewObj.ElementName
if($SensorType -eq 1 -and $sensorViewObj.OtherSensorTypeDescription -eq "Battery")
{
get-BatterySensorDiscovery -sensorDeviceID $sDeviceID -sensorElementName $sElementName
}
elseif($SensorType -eq 16)
{
get-IntrusionSensorDiscovery -sensorDeviceID $sDeviceID -sensorElementName $sElementName
}
elseif($SensorType -eq 2)
{
get-TemperatureSensorDiscovery -sensorDeviceID $sDeviceID -sensorElementName $sElementName
}
elseif($SensorType -eq 3)
{
get-VoltageSensorDiscovery -sensorDeviceID $sDeviceID -sensorElementName $sElementName
}
elseif($SensorType -eq 4)
{
get-CurrentSensorDiscovery -sensorDeviceID $sDeviceID -sensorElementName $sElementName
}
elseif($SensorType -eq 5)
{
get-FanSensorDiscovery -sensorDeviceID $sDeviceID -sensorElementName $sElementName
}
else{
#Do nothing
}
}
}

$sensorViewObj = Get-SensorObjectByElementName -elementName "Chassis Controller"
if ($sensorViewObj -ne $null )
{
get-ChassisControllerSensorDiscovery -sensorViewObj $sensorViewObj
}
}

function get-BatterySensorDiscovery
{
param($sensorDeviceID, $sensorElementName)
psDebugLog -level 1 -message "BatterySensorDiscovery is Started "
$sensorInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.BatterySensor']$")

$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']/ID$","SensorsGroup")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.BatterySensorGroup']/ID$","Battery Sensor Group")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.BatterySensor']/DeviceID$", $sensorDeviceID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.BatterySensor']/ElementName$", $sensorElementName)
$sensorInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $sensorDeviceID)
$discoveryData.AddInstance($sensorInst)
psDebugLog -level 1 -message "BatterySensorDiscovery is Ended "

}

function get-TemperatureSensorDiscovery
{
param($sensorDeviceID, $sensorElementName)
#psDebugLog -level 1 -message "TemperatureSensorDiscovery is Started "
$sensorInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.TemperatureSensor']$")

$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']/ID$","SensorsGroup")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.TemperatureSensorGroup']/ID$","Temperature Sensor Group")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.TemperatureSensor']/DeviceID$", $sensorDeviceID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.TemperatureSensor']/ElementName$", $sensorElementName)
$sensorInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $sensorDeviceID)
$discoveryData.AddInstance($sensorInst)
#psDebugLog -level 1 -message "TemperatureSensorDiscovery is Ended "

}

function get-VoltageSensorDiscovery
{
param($sensorDeviceID, $sensorElementName)
#psDebugLog -level 1 -message "VoltageSensorDiscovery is Started "
$sensorInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.VoltageSensor']$")

$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']/ID$","SensorsGroup")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.VoltageSensorGroup']/ID$","Voltage Sensor Group")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.VoltageSensor']/DeviceID$", $sensorDeviceID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.VoltageSensor']/ElementName$", $sensorElementName)
$sensorInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $sensorDeviceID)
$discoveryData.AddInstance($sensorInst)
#psDebugLog -level 1 -message "VoltageSensorDiscovery is Ended "

}

function get-CurrentSensorDiscovery
{
param($sensorDeviceID, $sensorElementName)
psDebugLog -level 1 -message "CurrentSensorDiscovery is Started "
$sensorInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.CurrentSensor']$")

$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']/ID$","SensorsGroup")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.CurrentSensorGroup']/ID$","Current Sensor Group")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.CurrentSensor']/DeviceID$", $sensorDeviceID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.CurrentSensor']/ElementName$", $sensorElementName)
$sensorInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $sensorDeviceID)
$discoveryData.AddInstance($sensorInst)
psDebugLog -level 1 -message "CurrentSensorDiscovery is Ended "

}

function get-FanSensorDiscovery
{
param($sensorDeviceID, $sensorElementName)
psDebugLog -level 1 -message "FanSensorDiscovery is Started "
$sensorInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.FanSensor']$")

$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']/ID$","SensorsGroup")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.FanSensorGroup']/ID$","Fan Sensor Group")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.FanSensor']/DeviceID$", $sensorDeviceID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.FanSensor']/ElementName$", $sensorElementName)
$sensorInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $sensorDeviceID)
$discoveryData.AddInstance($sensorInst)
psDebugLog -level 1 -message "FanSensorDiscovery is Ended "

}
function get-ChassisControllerSensorDiscovery
{
param($sensorViewObj)
psDebugLog -level 1 -message "ChassisControllerSensor Discovery is Started "
$sensorInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ChassisControllerSensor']$")

$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']/ID$","SensorsGroup")
$deviceID = formatString($sensorViewObj.DeviceID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ChassisControllerSensor']/DeviceID$", $deviceID)
$elementName = formatString($sensorViewObj.ElementName)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.ChassisControllerSensor']/ElementName$", $elementName)
$sensorInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $deviceID)
$discoveryData.AddInstance($sensorInst)
psDebugLog -level 1 -message "ChassisControllerSensorDiscovery is Ended "
}
function get-IntrusionSensorDiscovery
{
param($sensorDeviceID, $sensorElementName)
psDebugLog -level 1 -message "IntrusionSensorDiscovery is Started "
$sensorInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.IntrusionSensor']$")

$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.Sensors']/ID$","SensorsGroup")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.IntrusionSensorGroup']/ID$","Intrusion Sensor Group")
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.IntrusionSensor']/DeviceID$", $sensorDeviceID)
$sensorInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.IntrusionSensor']/ElementName$", $sensorElementName)
$sensorInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $sensorDeviceID)
$discoveryData.AddInstance($sensorInst)
psDebugLog -level 1 -message "IntrusionSensorDiscovery is Ended "

}

function get-ServerAVGSYSUsageDiscovery
{
psDebugLog -level 1 -message "get-ServerAVGSYSUsageDiscovery is Started "
foreach($dcimAggregationMetricValue in $dcimAggregationMetricValueArray)
{
$instanceID = $dcimAggregationMetricValue.InstanceID
$lcaseInstanceId = $instanceID.ToLower()
if (($lcaseInstanceId.Contains("systemboard")) -and ($lcaseInstanceId.Contains("avg")) -and ($lcaseInstanceId.Contains("sysusage")) -and ($lcaseInstanceId.Contains("1d")))
{
$avgSysUsageInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.AvgCUPSUtilizationPerDay']$")
$avgSysUsageInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$avgSysUsageInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.AvgCUPSUtilizationPerDay']/ID$", "Dell Server Capacity Threshold Check")
$avgSysUsageInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Dell Server Capacity Threshold Check")
$discoveryData.AddInstance($avgSysUsageInst)
}
}
psDebugLog -level 1 -message "get-ServerAVGSYSUsageDiscovery is Ended "
}
function Submit-EmptyDiscoveryData
{
$sinkInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellOperationsCommon!Dell.Discovery.Sink']$")
$sinkInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Dell Discovery Sink")
$principleName = get-itemproperty -path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Dell Computer Corporation\Dell Management Pack Suites'
$sinkInst.AddProperty("$MPElement[Name='DellOperationsCommon!Dell.Discovery.Sink']/Name$", $principleName.MSHostname)
$discoveryData.AddInstance($sinkInst)
}

# Check for System View exits. If not exists, Submit empty Discovery Data.
#$serverDiscoveryProceed = get-ServerDiscoveryProceed
If($false -eq $serverDiscoveryProceed)
{
Submit-EmptyDiscoveryData
}
else
{
$ServerInst = get-ManagedServerDiscovery
if($ServerInst -ne $null)
{
psDebugLog -level 1 -message "Created Discovery data"
if(($dcimProcInstArray -ne $null) -and ($dcimProcInstArray.count -gt 0))
{
get-ServerProcessorDiscovery
}
if(($dcimMemInstArray -ne $null) -and ($dcimMemInstArray.count -gt 0))
{
get-ServerMemoryDiscovery
}
get-ServerStorageDiscovery($ServerInst)

if(($dcimLicensegrpInstArray -ne $null) -and ($dcimLicensegrpInstArray.count -gt 0))
{
get-ServerLicenseGroupDiscovery
}
if(($dcimPowerSupplyViewArray -ne $null) -and ($dcimPowerSupplyViewArray.count -gt 0))
{
get-ServerPowerSupplies
}
if(($dcimHostNicViewArray -ne $null) -and ($dcimHostNicViewArray.count -gt 0))
{
$IsHostNicPresent = $false
foreach($hostNicInst in $dcimHostNicViewArray){
if($hostNicInst.DeviceFQDD[0] -ne $null){
$IsHostNicPresent = $true
break
}
}
if($IsHostNicPresent -eq $true){
get-ServerHostNicDiscovery
}
}
if(($dcimNicViewArray -ne $null) -and ($dcimNicViewArray.count -gt 0))
{
get-ServerNicDiscovery
}
if(($dcimSdcardViewArray -ne $null) -and ($dcimSdcardViewArray.count -gt 0))
{
get-ServerSDCards
}
if(($dcimiDracCardViewArray -ne $null) -and ($dcimiDracCardViewArray.count -gt 0))
{
get-ServeriDracAndNetworkInterfaceUnitDiscovery
}
if(($dcimSoftIdViewArray -ne $null) -and ($dcimSoftIdViewArray.count -gt 0))
{
get-ServerBiosDiscovery
}

if((($dcimSensorViewArray -ne $null) -and ($dcimSensorViewArray.count -gt 0)) -or (($dcimNumSensorViewArray -ne $null) -and ($dcimNumSensorViewArray.count -gt 0)))
{
get-ServerSensorDiscovery
}

if (($dcimAggregationMetricValueArray -ne $null) -and ($dcimAggregationMetricValueArray.Count -gt 0))
{
get-ServerAVGSYSUsageDiscovery
}

}
else
{
psDebugLog -level 1 -message "Creating Empty Discovery data"
Submit-EmptyDiscoveryData
}
}
$discoveryData
psDebugLog -level 1 -message ("Info: Dell Managed discovery End for Management Group "+$MGGroupName)
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>sourceID</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>managedEntityID</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>computerName</Name>
<Value>$Config/PrincipalName$</Value>
</Parameter>
<Parameter>
<Name>LogLevel</Name>
<Value>$Config/LogLevel$</Value>
</Parameter>
<Parameter>
<Name>DoDiscovery</Name>
<Value>$Config/DoDiscovery$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>1200</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DSP"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>