Dell FMP Host Management Server Discovery Data Source

Dell.FMPHost.Discovery.DataSource (DataSourceModuleType)

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

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

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval SecondsDell FMP Host Management Server Discovery Data Source Interval Seconds
TimeoutSecondsint$Config/TimeoutSeconds$Timeout SecondsDell FMP Host Management Server Discovery Data Source Timeout Seconds
LogLevelint$Config/LogLevel$Log LevelDell FMP Host Management Server Discovery Data Logging
FMPHostFqdnstring$Config/FMPHostFqdn$

Source Code:

<DataSourceModuleType ID="Dell.FMPHost.Discovery.DataSource" Accessibility="Internal" Batching="false">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>Windows!Microsoft.Windows.PowerShellSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element minOccurs="1" name="DellManagementSuiteId" type="xsd:string"/>
<xsd:element minOccurs="1" name="IntervalSeconds" type="xsd:int"/>
<xsd:element minOccurs="1" name="TimeoutSeconds" type="xsd:int"/>
<xsd:element minOccurs="1" name="LogLevel" type="xsd:int"/>
<xsd:element minOccurs="1" name="FMPType" type="xsd:string"/>
<xsd:element minOccurs="1" name="DMSType" type="xsd:string"/>
<xsd:element minOccurs="1" name="FMPHostFqdn" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
<OverrideableParameter ID="LogLevel" Selector="$Config/LogLevel$" ParameterType="int"/>
<OverrideableParameter ID="FMPHostFqdn" Selector="$Config/FMPHostFqdn$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>DellMgmtServerPicker.ps1</ScriptName>
<ScriptBody><Script>

# ------------------------------------------------- #
# Script : Management Server Picker Script #
# ------------------------------------------------- #

param($sourceID, $managedEntityID, $DMSId, $logLevel, $logDirectory, $FMPType, $DMSType, $FMPHostFqdn)
$MSComputerName = (hostname)
$DebugScript = $false

$DeviceMonitoringMPs = @{
'Dell.WindowsServer.Scalable' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'Server (inband)'; };
'Dell.WindowsServer.Detailed' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'Server (inband) Full'};
'Dell.OutOfBand.CMC' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'CMC and DRAC/MC'};
'Dell.OutOfBand.DRAC' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'DRAC 5, iDRAC6 and iDRAC7 (Modular &amp; Monolithic)'};
'Dell.CMC.OM07' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'CMC and DRAC/MC'};
'Dell.DRAC.OM07' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'DRAC 5, iDRAC6 and iDRAC7 (Modular &amp; Monolithic)'};
'Dell.CMC.OM12' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'CMC and DRAC/MC'};
'Dell.Chassis.Detailed' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'CMC'};
'Dell.DRAC.OM12' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'DRAC 5, iDRAC6 and iDRAC7 (Modular &amp; Monolithic)' };
'Dell.Connections.HardwareLibrary' = @{ 'MPType' = 'Library'; 'DeviceType' = 'Dell Folder' };
'Dell.Device.Definitions' = @{ 'MPType' = 'Library'; 'DeviceType' = 'Dell Devices Definitions' };
'Dell.Operations.Library' = @{ 'MPType' = 'Library'; 'DeviceType' = 'Dell Operations Library' };
'Dell.Server.OOB' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'Server Out of band (Scalable)'; };
'Dell.Server.OOB.DetailedMonitoringOn' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'Server Out of band Detailed'};
'Dell.ChassisModularServer.Correlation' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'Chassis Modular Server Correlation' };
'Dell.ChassisModularServer.Correlation.OM12' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'Chassis Modular Server Correlation' };
'Dell.EqualLogic.OM07' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'EqualLogic Storage (Scalable)'; };
'Dell.EqualLogic.OM12' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'EqualLogic Storage (Scalable)'; };
'Dell.EqualLogic.DetailedMonitoringOn' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'EqualLogic Storage Detailed'};
'Dell.Storage.EqualLogic' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'EqualLogic Storage (Scalable)'; };
'Dell.Storage.EqualLogic.DetailedMonitoringOn' = @{ 'MPType' = 'Device Monitor'; 'DeviceType' = 'EqualLogic Storage Detailed'};

}

$MonitoringFeaturesMap = @{
'Server and Rack Workstation Agent-based Monitoring' = @{ 'Dell.WindowsServer.Scalable' = 'Scalable Feature'; 'Dell.WindowsServer.Detailed' = 'Detailed Feature' }
'Chassis Monitoring' = @{ 'Dell.OutOfBand.CMC' = 'Full Feature'; 'Dell.CMC.OM07' = 'Scalable Feature' ; 'Dell.CMC.OM12' = 'Scalable Feature' ; 'Dell.Chassis.Detailed' = 'Detailed Feature'};
'DRAC Monitoring' = @{ 'Dell.OutOfBand.DRAC' = 'Full Feature'; 'Dell.DRAC.OM07' = 'Full Feature' ; 'Dell.DRAC.OM12' = 'Full Feature' ; };
'Chassis Modular Server Correlation' = @{ 'Dell.ChassisModularServer.Correlation' = 'Full Feature'; 'Dell.ChassisModularServer.Correlation.OM12' = 'Full Feature'; };
'Server and Rack Workstation Agent-free Monitoring' = @{ 'Dell.Server.OOB' = 'Scalable Feature'; 'Dell.Server.OOB.DetailedMonitoringOn' = 'Detailed Feature';};
'EqualLogic Monitoring' = @{ 'Dell.Storage.EqualLogic' = 'Scalable Feature'; 'Dell.Storage.EqualLogic.DetailedMonitoringOn' = 'Detailed Feature'; 'Dell.EqualLogic.OM07' = 'Scalable Feature' ; 'Dell.EqualLogic.OM12' = 'Scalable Feature' ; 'Dell.EqualLogic.DetailedMonitoringOn' = 'Detailed Feature';};
}

$LicensedFeaturesMap = @{
'Server and Rack Workstation Agent-based Monitoring' = $false;
'Chassis Monitoring' = $false;
'DRAC Monitoring' = $false;
'Chassis Modular Server Correlation' = $false;
'Server and Rack Workstation Agent-free Monitoring' = $true;
'EqualLogic Monitoring' = $false;
}

$DescriptionMap = @{
'Server and Rack Workstation Agent-based Monitoring' = 'Monitor Dell PowerEdge and PowerVault Servers through Agent-based management channel';
'Chassis Monitoring' = 'Monitor Dell chassis devices i.e. CMCs and DRAC/MCs';
'DRAC Monitoring' = 'Monitor Dell remote access devices i.e. DRAC5, iDRACs';
'Chassis Modular Server Correlation' = 'Perform correlation between Dell Chassis and Dell Modular Server';
'Server and Rack Workstation Agent-free Monitoring' = 'Monitor Dell PowerEdge Servers through Agent-free management channel';
'EqualLogic Monitoring' = 'Monitor Dell EqualLogic Storage Array devices';
}

$MonitoringFeatures = @{
'Server and Rack Workstation Agent-based Monitoring' = @( 'Dell.WindowsServer.Scalable'; 'Dell.WindowsServer.Detailed' )
'Chassis Monitoring' = @( 'Dell.OutOfBand.CMC', 'Dell.CMC.OM07','Dell.CMC.OM12','Dell.Chassis.Detailed')
'DRAC Monitoring' = @( 'Dell.OutOfBand.DRAC', 'Dell.DRAC.OM07', 'Dell.DRAC.OM12')
'Chassis Modular Server Correlation' = @( 'Dell.ChassisModularServer.Correlation', 'Dell.ChassisModularServer.Correlation.OM12')
'Server and Rack Workstation Agent-free Monitoring' = @( 'Dell.Server.OOB', 'Dell.Server.OOB.DetailedMonitoringOn')
'EqualLogic Monitoring' = @( 'Dell.EqualLogic.Impl', 'Dell.Storage.EqualLogic', 'Dell.Storage.EqualLogic.DetailedMonitoringOn', 'Dell.EqualLogic.OM07', 'Dell.EqualLogic.OM12', 'Dell.EqualLogic.DetailedMonitoringOn')
}


if( $FMPType -eq "SuiteEqualLogic")
{
$scriptname = "DellFMP_EqualLogic"
}

if( $FMPType -eq "SuiteServer")
{
$scriptname = "DellFMP_Server"
}

[Threading.Thread]::CurrentThread.CurrentCulture = "en-US"
[Threading.Thread]::CurrentThread.CurrentUICulture = "en-US"

# ------------------------------------------------------------------------------------------
# Function to convert Management Pack version and formatted for 3 digits.
# ------------------------------------------------------------------------------------------
function VerToString
{
param($version)
$myver = "Not Installed"
if($version -eq "0")
{
return $myver
}
$verLength = ([string]$version).Length
if($verLength -le 3)
{
return ([string]$version).Substring(0,3)
}
if($verLength -ge 5)
{
return ([string]$version).Substring(0,5)
}

}

# ------------------------------------------------------------------------------------------
# Function to Round-off
# ------------------------------------------------------------------------------------------
function Round( $value, [MidpointRounding]$mode = 'AwayFromZero' ) { [Math]::Round( $value, $mode ) }

# ------------------------------------------------------------------------------------------
# Function to get Server Version
# ------------------------------------------------------------------------------------------
function GetServerVersion()
{
param($KeyToFind)
$MPLocRegKeyPath = "HKLM:\software\Dell\Dell Server Management Pack Suites";
$mpLoc = $null;
$mpLoc = Get-ItemProperty -path:$MPLocRegKeyPath -name:$KeyToFind -ErrorAction:SilentlyContinue;
return $mpLoc;
}

# ------------------------------------------------------------------------------------------
# Function to get Equallogic Suite Version
# ------------------------------------------------------------------------------------------
function GetEqualLogicVersion()
{
param($KeyToFind)
$MPLocRegKeyPath = "HKLM:\SOFTWARE\Dell\Dell EqualLogic Storage Management Pack Suite";
$mpLoc = $null;
$mpLoc = Get-ItemProperty -path:$MPLocRegKeyPath -name:$KeyToFind -ErrorAction:SilentlyContinue;
return $mpLoc;
}

# --------------------------------------------------------------------------------------
# Function to get the registry keys (Path and LicenseWebServerURL) from Windows registry
# --------------------------------------------------------------------------------------
function GetMPLocationFromRegistry()
{
param($KeyToFind)
$MPLocRegKeyPath = "HKLM:\software\Dell\Dell Server Management Pack Suites";
$mpLoc = $null;
$mpLoc = Get-ItemProperty -path:$MPLocRegKeyPath -name:$KeyToFind -ErrorAction:SilentlyContinue;
return $mpLoc;
}

# --------------------------------------------------------------------------------------------------------------------
# Function to instantiate Management Feature instances if they are detected, else create Scalable Feature instances
# Dell.FeatureManagement.MonitoringFeature - base class of any feature, one instance will always be created
# Specialized MonFeature instance will be created based on presence (install) of the corresponding feature
# This is useful for displaying only applicable tasks on a feature (installed feature)
# ---------------------------------------------------------------------------------------------------------------------
function CreateMP
{
param($Discovery, $name, $desc, $avail, $version, $config, $license)

if ($debugscript -eq $false)
{
$Instance1 = $null
if ($version -eq "0")
{
# $name = "!-" + $name
# psDebugLog -level 1 -message (" -------- NotInstalled feature detected" + $name)
# if feature is not installed
if ($name.Contains("Chassis Modular Server Correlation"))
{
$Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.NotInstalled.SimpleFeature.CBC']$")
psDebugLog -level 1 -message (" -------- Adding NotInstalled feature instance - " + $name)
}
elseif ($name.Contains("Chassis Monitoring"))
{
$Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.NotInstalled.SimpleFeature.CMC']$")
psDebugLog -level 1 -message (" -------- Adding NotInstalled feature instance - " + $name)
}
elseif ($name.Contains("Server and Rack Workstation Agent-free Monitoring"))
{
$Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.NotInstalled.ComplexFeature.ServerOOB']$")
psDebugLog -level 1 -message (" -------- Adding NotInstalled feature instance - " + $name)
}
elseif ($name.Contains("DRAC Monitoring"))
{
$Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.NotInstalled.SimpleFeature.DRAC']$")
psDebugLog -level 1 -message (" -------- Adding NotInstalled feature instance - " + $name)
}
elseif ($name.Contains("Server and Rack Workstation Agent-based Monitoring"))
{
$Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.NotInstalled.ComplexFeature.ServerIB']$")
psDebugLog -level 1 -message (" -------- Adding NotInstalled feature instance - " + $name)
}
else
{
# $Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.NotInstalled']$")
psDebugLog -level 1 -message (" -------- Unknown feature Not-Installed instance encountered - " + $name)
}
}
else
{
psDebugLog -level 1 -message (" -------- Installed feature detected")
# feature is installed
if ($name.Contains("Chassis Modular Server Correlation"))
{
$Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.Installed.SimpleFeature.CBC']$")
psDebugLog -level 1 -message (" -------- Adding installed feature instance - " + $name)
}
elseif ($name.Contains("Chassis Monitoring"))
{
$Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.Installed.SimpleFeature.CMC']$")
psDebugLog -level 1 -message (" -------- Adding installed feature instance - " + $name)
}
elseif ($name.Contains("Server and Rack Workstation Agent-free Monitoring"))
{
$Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.Installed.ComplexFeature.ServerOOB']$")
psDebugLog -level 1 -message (" -------- Adding installed feature instance - " + $name)
}
elseif ($name.Contains("DRAC Monitoring"))
{
$Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.Installed.SimpleFeature.DRAC']$")
psDebugLog -level 1 -message (" -------- Adding installed feature instance - " + $name)
}
elseif ($name.Contains("Server and Rack Workstation Agent-based Monitoring"))
{
$Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.Installed.ComplexFeature.ServerIB']$")
psDebugLog -level 1 -message (" -------- Adding installed feature instance - " + $name)
}
else
{
#$Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.Installed']$")
psDebugLog -level 1 -message (" -------- Unknown feature Installed instance encountered - " + $name)
}
}
if($Instance1 -ne $null)
{
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/FeatureName$", $name)
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/Description$", $desc)
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/InUseVersion$", (VerToString -version $version))
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/ExtractedVersion$", (VerToString -version $avail))
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/MonitoringLevel$", $config)

#$sysinfo = Get-WmiObject -Class Win32_ComputerSystem
#$localFqdn = "{0}.{1}" -f $sysinfo.Name, $sysinfo.Domain

$sysinfo = Get-ItemProperty -Path "HKLM:\SOFTWARE\Dell Computer Corporation\Dell Management Pack Suites"
$localFqdn = $sysinfo.MSHostName
if( $localFqdn -eq $null -or $localFqdn.Length -eq 0 )
{
$sysinfo = [System.Net.Dns]::GetHostEntry([string]$env:computername)
$localFqdn = $sysinfo.HostName
}

$Instance1.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $localFqdn)
psDebugLog -level 1 -message (" -------- Adding Monitoringfeature Host Server's local FQDN (hostKey) - " + $localFqdn)

$serverObj = $null
$srvcls = $null
$nodecount=0

if ($name.Contains("Chassis Monitoring")){
$srvcls = $scomenv.GetClassDetails("Dell.ModularChassis.CMC")
psDebugLog -level 1 -message (" -------- Node Count CMC")
if ($srvcls -ne $null){
$serverObj = $scomenv.GetSCOMClassInstance($srvcls)
if($serverObj -ne $null){
$nodecount=($serverObj | measure).Count
}
}
}
elseif ($name.Contains("Server and Rack Workstation Agent-free Monitoring"))
{
$srvcls = $scomenv.GetClassDetails("Dell.Server")
psDebugLog -level 1 -message (" -------- Node Count OOB")
if ($srvcls -ne $null){
psDebugLog -level 1 -message (" -------- Inside Node Count OOB1 ::")
$serverObj = $scomenv.GetSCOMClassInstance($srvcls)
if($serverObj -ne $null){
$nodecount=($serverObj | measure).Count
psDebugLog -level 1 -message (" -------- Inside Node Count OOB ::"+ $nodecount)
}
}
}
elseif ($name.Contains("DRAC Monitoring"))
{
$srvcls = $scomenv.GetClassDetails("Dell.RemoteAccess.RAC")
psDebugLog -level 1 -message (" -------- Node Count DRAC")
if ($srvcls -ne $null){
$serverObj = $scomenv.GetSCOMClassInstance($srvcls)
if($serverObj -ne $null){
$nodecount=($serverObj | measure).Count
}
}
}
elseif ($name.Contains("Server and Rack Workstation Agent-based Monitoring"))
{

$srvcls = $scomenv.GetClassDetails("Dell.WindowsServer.Server")
psDebugLog -level 1 -message (" -------- Node Count Windows")
if ($srvcls -ne $null){
$serverObj = $scomenv.GetSCOMClassInstance($srvcls)
if($serverObj -ne $null){
$nodecount=($serverObj | measure).Count
}
}
}
else{
$nodecount = "Not Applicable"
}

psDebugLog -level 1 -message (" -------- Final Node Count :" + $nodecount)

if($name.Contains("Server and Rack Workstation Agent-free Monitoring")){
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/TotalNodeLicense$", $nodecount)
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/LicensesInUse$", $nodecount)
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/CurrentLicenseUsage$", "Yes")
psDebugLog -level 1 -message (" --------Final Log Agent-free Monitoring:" + $nodecount)
}
else{
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/TotalNodeLicense$", $nodecount)
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/LicensesInUse$", "Not Applicable")
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/CurrentLicenseUsage$", "No")
}
$Discovery.AddInstance($Instance1)
}
}
}


# ----------------------------------------------------------------------
# Function to invoke primary discoover wrt SCOM objects and environment
# ----------------------------------------------------------------------
function CallPrimaryDiscoveryScript
{
param ($Discovery, $SCOMEnv)

$visitor = @{}
# Initialize an array of MPNames as null for each
foreach ($mp in $DeviceMonitoringMPs.Keys)
{
$visitor += @{ $mp = $null }
}

# Initialize an array of FeatureVisitor, Map and Version as default value for each (displayed if not otherwise set)
$featurevisitor = @{}
$featuremap = @{}
$featurever = @{}

foreach ($feature in $MonitoringFeaturesMap.Keys)
{
$featurevisitor += @{ $feature = $false }
$featuremap += @{ $feature = "" }
$featurever += @{ $feature = "0" }
}

# gets all SCOM management packs which fit criteria of listing in $DeviceMonitoringMPs ARRAY and if present in that list, VisitorMap[MP] is set to value
$SCOMEnv.GetManagementPacks() | where-object { $DeviceMonitoringMPs.Contains($_.Name) } | foreach -process {
$visitor[$_.Name] = $_
}

foreach ($feature in $MonitoringFeaturesMap.Keys)
{
foreach ($mp in $MonitoringFeatures[$feature])
{
if ($mp -ne $null -and $visitor[$mp] -ne $null)
{
$featurevisitor[$feature] = $true
if ($MonitoringFeaturesMap[$feature][$mp] -eq 'Detailed Feature')
{
$featuremap[$feature] = 'Detailed Feature'
}
elseif ($featuremap[$feature] -ne 'Detailed Feature')
{
$featuremap[$feature] = $MonitoringFeaturesMap[$feature][$mp]
}
$featurever[$feature] = $visitor[$mp].Version
}
}

}
# REVISIT: Read this from registry
$mpsuiteRegKey = Get-ItemProperty 'HKLM:\SOFTWARE\Dell\Dell Server Management Pack Suites'
$avail = $mpsuiteRegKey.CurrentVersion
psDebugLog -level 1 -message ("Available Server Managment Pack Suite Version is " + $avail + "-------")
foreach ($feature in $MonitoringFeatures.Keys)
{
if ($featuremap[$feature] -eq '')
{
$featuremap[$feature] = 'Not Installed'
}
psDebugLog -level 1 -message ("CallPrimaryDiscoveryScript Loop :: -- " + $feature + " -- " + $featuremap[$feature] + " -- " + $featurever[$feature] + " -- " + $avail + " -- ")
CreateMP -Discovery $Discovery -name $feature -desc $DescriptionMap[$feature] -config $featuremap[$feature] -license $LicensedFeaturesMap[$feature] -version $featurever[$feature] -avail $avail


}
}

#----------------------------------------------------------------------------
# Function to invoke create Equal MP wrt SCOM objects and environment
#----------------------------------------------------------------------------

function CreateEqlMP
{
param($Discovery, $name, $desc, $avail, $version, $config, $license)

if ($debugscript -eq $false)
{
$Instance1 = $null
if ($version -eq "0")
{
if ($name.Contains("EqualLogic Monitoring"))
{
$Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.NotInstalled.ComplexFeature.EqualLogic']$")
psDebugLog -level 1 -message (" -------- Adding NotInstalled feature instance - " + $name)
}
else
{
# $Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.NotInstalled']$")
psDebugLog -level 1 -message (" -------- Not a EqualLogic feature - " + $name)
}
}
else
{
psDebugLog -level 1 -message (" -------- Installed feature detected")
# feature is installed
if ($name.Contains("EqualLogic Monitoring"))
{
$Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.Installed.ComplexFeature.EqualLogic']$")
psDebugLog -level 1 -message (" -------- Adding installed feature instance - " + $name)
}
else
{
#$Instance1 = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature.Installed']$")
psDebugLog -level 1 -message (" -------- Unknown feature Installed instance encountered - " + $name)
}
}
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/FeatureName$", $name)
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/Description$", $desc)
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/InUseVersion$", (VerToString -version $version))
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/ExtractedVersion$", (VerToString -version $avail))
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/MonitoringLevel$", $config)

#$sysinfo = Get-WmiObject -Class Win32_ComputerSystem
#$localFqdn = "{0}.{1}" -f $sysinfo.Name, $sysinfo.Domain
$sysinfo = Get-ItemProperty -Path "HKLM:\SOFTWARE\Dell Computer Corporation\Dell Management Pack Suites"
$localFqdn = $sysinfo.MSHostName
if( $localFqdn -eq $null -or $localFqdn.Length -eq 0 )
{
$sysinfo = [System.Net.Dns]::GetHostEntry([string]$env:computername)
$localFqdn = $sysinfo.HostName
}

$Instance1.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $localFqdn)
psDebugLog -level 1 -message (" -------- Adding Monitoring feature Host Server's local FQDN (hostKey) - " + $localFqdn)
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/TotalNodeLicense$", "Not Applicable")
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/LicensesInUse$", "Not Applicable")
$Instance1.AddProperty("$MPElement[Name='Dell.FeatureManagement.MonitoringFeature']/CurrentLicenseUsage$", "Not Applicable")

$Discovery.AddInstance($Instance1)
}
}

#----------------------------------------------------------------------------
# Function to invoke Equal primary discovery wrt SCOM objects and environment
#----------------------------------------------------------------------------
function CallEqlPrimaryDiscoveryScript
{
param ($Discovery, $SCOMEnv)

$visitor = @{}
# Initialize an array of MPNames as null for each
foreach ($mp in $DeviceMonitoringMPs.Keys)
{
$visitor += @{ $mp = $null }
}

# Initialize an array of FeatureVisitor, Map and Version as default value for each (displayed if not otherwise set)
$featurevisitor = @{}
$featuremap = @{}
$featurever = @{}

foreach ($feature in $MonitoringFeaturesMap.Keys)
{
$featurevisitor += @{ $feature = $false }
$featuremap += @{ $feature = "" }
$featurever += @{ $feature = "0" }
}

# gets all SCOM management packs which fit criteria of listing in $DeviceMonitoringMPs ARRAY and if present in that list, VisitorMap[MP] is set to value
$SCOMEnv.GetManagementPacks() | where-object { $DeviceMonitoringMPs.Contains($_.Name) } | foreach -process {
$visitor[$_.Name] = $_
}

foreach ($feature in $MonitoringFeaturesMap.Keys)
{
foreach ($mp in $MonitoringFeatures[$feature])
{
if ($mp -ne $null -and $visitor[$mp] -ne $null)
{
$featurevisitor[$feature] = $true
if ($MonitoringFeaturesMap[$feature][$mp] -eq 'Detailed Feature')
{
$featuremap[$feature] = 'Detailed Feature'
}
elseif ($featuremap[$feature] -ne 'Detailed Feature')
{
$featuremap[$feature] = $MonitoringFeaturesMap[$feature][$mp]
}
$featurever[$feature] = $visitor[$mp].Version
}
}

}
# Read this from registry
$mpsuiteRegKey=Get-ItemProperty 'HKLM:\SOFTWARE\Dell\Dell EqualLogic Storage Management Pack Suite'
$avail = $mpsuiteRegKey.CurrentVersion

foreach ($feature in $MonitoringFeatures.Keys)
{
if ($featuremap[$feature] -eq '') { $featuremap[$feature] = 'Not Installed' }
CreateEqlMP -Discovery $Discovery -name $feature -desc $DescriptionMap[$feature] -config $featuremap[$feature] -license $LicensedFeaturesMap[$feature] -version $featurever[$feature] -avail $avail
psDebugLog -level 1 -message ("CallEqlPrimaryDiscoveryScript Loop :: -- " + $feature + " -- " + $featuremap[$feature] + " -- " + $featurever[$feature] + " -- " + $avail + " -- ")
}
}

# ----------------------------------------------------------------------
# Function to create the log files in Temp folder
# ----------------------------------------------------------------------
if ($logLevel -ne 0)
{
$TempFolder = [environment]::GetEnvironMentVariable("temp","machine")
$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 -type file
}
}
}


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
}
}

# -----------------------------------------------------------------------------------
# Creating new SCE2010 Module - for connection to SCE and SCE task functionality
# -----------------------------------------------------------------------------------
$sce2010Interface = new-module {
[object]$connection = $null
[string] $state = ''
[string] $loglocation = '.\test.log'
[int] $loglevel = 1
[string] $product = "SCE 2010"


function Write-Info
{
param ([string] $msg)
#Write-Host $msg
}

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 $this.loglocation -InputObject ($currentTime + " :: " + $message) -Append
}
}

function GetConnection()
{
psDebugLog -level 1 -message $this.state
$this.connection = [Microsoft.EnterpriseManagement.ManagementGroup]::connect("localhost")
$this.state = 'connected'
}

function LoadSnapins()
{
$regSCEPathValue = $null;
$regSCEPathValue = $(Get-ItemProperty "HKLM:\software\Microsoft\System Center Essentials\2.0\Setup\Components").installpath;
psDebugLog -level 1 -message ("SCE Path found = " + $regSCEPathValue)
[System.Reflection.Assembly]::LoadFile($regSCEPathValue + "\SDK Binaries\Microsoft.EnterpriseManagement.OperationsManager.Common.dll") &gt; $null
[System.Reflection.Assembly]::LoadFile($regSCEPathValue + "\SDK Binaries\Microsoft.EnterpriseManagement.OperationsManager.dll") &gt; $null
$this.state = 'snapins loaded'
}

Function GetManagementPacks()
{
psDebugLog -level 1 -message $this.state
return $this.connection.GetManagementPacks()
}

function InstallManagementPack($ImportPath)
{
$v = $null
try {
$this.connection.ImportManagementPack($ImportPath)
} catch {
$v = $_
}
return $v
}

function UninstallManagementPack($ManagementPack)
{
$this.connection.UninstallManagementPack($ManagementPack)
$v = $null
return $v
}

function PrintDebug()
{
Write-Info -msg ("Product: " + $this.Product)
Write-Info -msg ("State: " + $this.State)
}

function GetSCOMInstallDir()
{
return $(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup").InstallDirectory;
}

function GetManagementGroup()
{
return $this.connection
}

function IsSCE2010()
{
return $true
}

function IsSCOM2007R2()
{
return $false
}

function IsSCOM2012()
{
return $false
}

Export-ModuleMember -function * -variable *
} -asCustomObject

# -----------------------------------------------------------------------------------
# Creating new SCOM2007 R2 Module - for connection to 2007R2 and 2007R2 task functionality
# -----------------------------------------------------------------------------------
$scom2007r2Interface = new-module {
[object]$connection = $null
[string] $state = ''
[string] $loglocation = '.\test.log'
[int] $loglevel = 1
[string] $product = "SCOM 2007 R2"
[string] $EqualLogicRegistry = "False"
[string] $ServerRegistry = "False"

function Write-Info
{
param ([string] $msg)
#Write-Host $msg
}

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 $this.loglocation -InputObject ($currentTime + " :: " + $message) -Append
}
}

function GetConnection()
{
psDebugLog -level 1 -message $this.state
$MachineRegErrorMsg = "Can not find Operations Manager Management Server name for the local machine.";
$UserRegKeyPath = "HKCU:\software\Microsoft\Microsoft Operations Manager\3.0\User Settings";
$MachineRegKeyPath = "HKLM:\software\Microsoft\Microsoft Operations Manager\3.0\Machine Settings";
$UserRegValueName = "SDKServiceMachine";
$MachineRegValueName = "DefaultSDKServiceMachine";
$ConnectingMsg = "Connecting to Operations Manager Management Server '{0}'.";
$ConnectErrorMsg = "Can not connect to Operations Manager Management Server '{0}'.";
$AccessDeniedErrorMsg = "Access is denied to Operations Manager Management Server '{0}'.";

$regKey = $null;
$regValue = $null;

# Set the initial server value to the MS argument.
# If the argument is empty the normal registry lookup sequence will kickin.
# If the argument is not empty the user will be connected to the specified connection.
$server = $null;

# Get the User Operations Manager Product Registry Key
if ($server -eq $null -or $server.Length -eq 0)
{
$regValue = Get-ItemProperty -path:$UserRegKeyPath -name:$UserRegValueName -ErrorAction:SilentlyContinue;

if ($regValue -ne $null)
{
$server = $regValue.SDKServiceMachine;
}
}

if ($server -eq $null -or $server.Length -eq 0)
{
# Get the Machine Operations Manager Product Registry Key if the user setting could not be found.
$regValue = Get-ItemProperty -path:$MachineRegKeyPath -name:$MachineRegValueName -ErrorAction:SilentlyContinue;

if ($regValue -ne $null)
{
$server = $regValue.DefaultSDKServiceMachine;
}
}

# If the default Operations Manager Management Server name can not be found in the registry then default to 'localhost'.
if ($server -eq $null -or $server.Length -eq 0)
{
psDebugLog -level 1 -message ($MachineRegErrorMsg)
$server = "localhost";
}

# Create a connection and make it the current location.
if ($server -ne $null -and $server.Length -gt 0)
{
# Format the connecting message.
$msg = $ConnectingMsg -f $server;
psDebugLog -level 1 -message ($msg)

# Create the new connection.
$error.Clear();
$this.connection = New-ManagementGroupConnection -ConnectionString:$server -ErrorAction:SilentlyContinue
psDebugLog -level 1 -message ("After : " + $msg)
if ($this.connection -ne $null)
{
psDebugLog -level 1 -message ("Connection Success! " + $this.connection)
}

# If the connection failed due to insufficient access then prompt for credentials.
if ($error.Count -gt 0 -and $error[0].Exception -is [Microsoft.EnterpriseManagement.Common.UnauthorizedAccessMonitoringException])
{
psDebugLog -level 1 -message ("Failed to connect")
$error.Clear();
}

if ($error.Count -gt 0 -and $error[0].Exception -is [Microsoft.EnterpriseManagement.Common.UnauthorizedAccessMonitoringException])
{
$errMsg = $AccessDeniedErrorMsg -f $server;
psDebugLog -level 1 -message $errMsg
}

if ($this.connection -eq $null)
{
$errMsg = $ConnectErrorMsg -f $server;
psDebugLog -level 1 -message $errMsg
}
}

if ($this.connection -ne $null)
{
psDebugLog -level 1 -message ("Setting to path: " + "OperationsManagerMonitoring::")
Set-Location "OperationsManagerMonitoring::"
psDebugLog -level 1 -message ("Current Directory: " + (pwd).Path)
psDebugLog -level 1 -message ("Setting to path: " + $server)
Set-Location $server;
psDebugLog -level 1 -message ("Current Directory: " + (pwd).Path)
}
$this.state = 'connected'
return $this.connection
}

function LoadSnapins()
{
$snapin = (Get-PsSnapin Microsoft.EnterpriseManagement.OperationsManager.Client -ErrorVariable $snapinerr -ErrorAction:SilentlyContinue)
if ($snapin -eq $null)
{
Add-PsSnapin Microsoft.EnterpriseManagement.OperationsManager.Client -ErrorVariable $snapinerr -ErrorAction:SilentlyContinue
if ($snapinerr -eq $null -or $snapinerr.Count -eq 0) {
psDebugLog -level 1 -message "Snapin succeeded"
}
else
{
psDebugLog -level 1 -message "Snapin Failed"
psDebugLog -level 1 -message $snapinerr
}
}
$this.state = 'snapins loaded'
}

function PrintDebug()
{
Write-Info -msg ("Product: " + $this.Product)
Write-Info -msg ("State: " + $this.State)
}

function GetManagementGroup()
{
return $this.connection.ManagementGroup
}

function IsSCOM2007R2()
{
return $true
}

function IsSCOM2012()
{
return $false
}

function GetManagementPacks()
{
psDebugLog -level 1 -message $this.state
return (Get-ManagementPack)
}

function InstallManagementPack($ImportPath)
{
Install-ManagementPack -filepath $ImportPath -ErrorAction:SilentlyContinue -ErrorVariable v
return $v
}

function UninstallManagementPack($ManagementPack)
{
Uninstall-ManagementPack -ManagementPack $ManagementPack -ErrorAction:SilentlyContinue -ErrorVariable v
return $v
}

function GetManagementGroup()
{
return $this.connection.ManagementGroup
}

function GetSCOMInstallDir()
{
return $(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup").InstallDirectory;
}

function IsSCOM2007R2()
{
return $true
}

function IsSCOM2012()
{
return $false
}

Export-ModuleMember -function * -variable *
} -asCustomObject

# -----------------------------------------------------------------------------------
# Creating new SCOM2012 Module - for connection to 2012 and 2012 task functionality
# -----------------------------------------------------------------------------------
$scom2012Interface = new-module {
[object]$connection = $null
[string] $state = ''
[string] $loglocation = '.\test.log'
[int] $loglevel = 1
[string] $product = "SCOM 2012"
[string] $EqualLogicRegistry = "False"
[string] $ServerRegistry = "False"

function Write-Info
{
param ([string] $msg)
#Write-Host $msg
}

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 $this.loglocation -InputObject ($currentTime + " :: " + $message) -Append
}
}
function GetConnection()
{
psDebugLog -level 1 -message $this.state
$managementServerName = ""
$persistConnection = $false
$interactive = $false
$MachineRegErrorMsg = "Can not find Operations Manager Management Server name for the local machine.";
$UserRegKeyPath = "HKCU:\software\Microsoft\Microsoft Operations Manager\3.0\User Settings";
$MachineRegKeyPath = "HKLM:\software\Microsoft\Microsoft Operations Manager\3.0\Machine Settings";
$UserRegValueName = "SDKServiceMachine";
$MachineRegValueName = "DefaultSDKServiceMachine";
$ConnectingMsg = "Connecting to Operations Manager Management Server '{0}'.";
$ConnectErrorMsg = "Can not connect to Operations Manager Management Server '{0}'.";
$AccessDeniedErrorMsg = "Access is denied to Operations Manager Management Server '{0}'.";
$ConnectPromptMsg = "Enter the name of the Operations Manager Management Server to connect to.";
$ConnectPrompt = "Management Server";
$serviceNotRunningErrorMsg = "The Data Access service is either not running or not yet initialized. Check the event log for more information.";
$HostNotFoundErrorMsg = "No such host is known";

$regKey = $null;
$regValue = $null;

# Set the initial server value to the MS argument.
# If the argument is empty the normal registry lookup sequence will kickin.
# If the argument is not empty the user will be connected to the specified connection.
$server = $managementServerName;
$drive = $null;

# Get the User Operations Manager Product Registry Key
if ($server -eq $null -or $server.Length -eq 0)
{
$regValue = Get-ItemProperty -path:$UserRegKeyPath -name:$UserRegValueName -ErrorAction:SilentlyContinue;

if ($regValue -ne $null)
{
$server = $regValue.SDKServiceMachine;
}
}

if ($server -eq $null -or $server.Length -eq 0)
{
# Get the Machine Operations Manager Product Registry Key if the user setting could not be found.
$regValue = Get-ItemProperty -path:$MachineRegKeyPath -name:$MachineRegValueName -ErrorAction:SilentlyContinue;

if ($regValue -ne $null)
{
$server = $regValue.DefaultSDKServiceMachine;
}
}

# If the default Operations Manager Management Server name can not be found in the registry then default to 'localhost'.
if ($server -eq $null -or $server.Length -eq 0)
{
psDebugLog -level 1 -message $MachineRegErrorMsg
$server = "localhost";
}

# Create a connection and make it the current location.
$this.connection = $null;

if ($server -ne $null -and $server.Length -gt 0)
{
# Format the connecting message.
$msg = $ConnectingMsg -f $server;
psDebugLog -level 1 -message $msg

# Create the new connection.
$this.connection = New-SCOMManagementGroupConnection -ComputerName: $server -PassThru -ErrorAction:Stop
}
$this.state = 'connected'
return $this.connection
}

function PrintDebug()
{
Write-Info -msg ("Product: " + $this.Product)
Write-Info -msg ("State: " + $this.State)
}

function LoadSnapins()
{
Import-Module OperationsManager
$this.state = 'snapins loaded'
}

function GetManagementGroup()
{
return $this.mgmtGroup
}

function IsSCOM2007R2()
{
return $false
}

function IsSCOM2012()
{
return $true
}

Function GetManagementPacks()
{
psDebugLog -level 1 -message $this.state
return (Get-SCManagementPack)
}

function InstallManagementPack($ImportPath)
{
Import-SCManagementPack $ImportPath -ErrorAction:SilentlyContinue -ErrorVariable v
return $v
}

function UninstallManagementPack($ManagementPack)
{
Remove-SCManagementPack -ManagementPack $ManagementPack -ErrorAction:SilentlyContinue -ErrorVariable v
return $v
}

function GetSCOMInstallDir()
{
return $(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup").InstallDirectory;
}

function GetManagementGroup()
{
return $this.mgmtGroup
}
Function GetClassDetails($className)
{
return (Get-SCOMClass | where { $_.Name -eq $className })
}
Function GetSCOMClassInstance($className)
{
return (Get-SCOMClassInstance -Class $className | select *)
}
function mySCOMInitiateTask($string1,$string2)
{
$overrideObj = @{'TimeoutSeconds'='3600'; 'Force'='True'}
$instanceObj = Get-SCOMClassInstance -DisplayName ($string1)
$taskObj = Get-SCOMTask -DisplayName ($string2)
Start-SCOMTask -Task $taskobj -Instance $instanceObj -Override $overrideObj
Start-Sleep -s 10
$taskMsg = Get-SCOMTaskResult
return $taskMsg.Output
}

function IsSCOM2007R2()
{
return $false
}

function IsSCOM2012()
{
return $true
}

Export-ModuleMember -function * -variable *
} -asCustomObject

#-----------------------------------------------------------------------------------
# Check the Operations Manager Environment
#-----------------------------------------------------------------------------------
$MachineRegKeyPath = "HKLM:\software\Microsoft\Microsoft Operations Manager\3.0\Setup";
$MachineRegValueName = "InstallDirectory";
$skuName = $null; $skuVersion = $null
$skuName = Get-ItemProperty -path:$MachineRegKeyPath -name:$MachineRegValueName -ErrorAction:SilentlyContinue;
$skuVersion = Get-ItemProperty -path:$MachineRegKeyPath -name:"CurrentVersion" -ErrorAction:SilentlyContinue;

if ( $skuName.InstallDirectory -match "2007" )
{
$scomenv = $scom2007r2Interface
}
elseif( $skuName.InstallDirectory -match "2012" )
{
$scomenv = $scom2012Interface
}

$scomenv.loglocation = $LogFileLocation
$scomenv.LogLevel = $LogLevel
$scomenv.LoadSnapins()
$scomenv.PrintDebug()
$scomenv.GetConnection()

psDebugLog -level 1 -message ("----------------------------------------------")
psDebugLog -level 1 -message ("Begin of " + $scriptname + " Discovery script ")
psDebugLog -level 1 -message ("Ops Mgr InstallDirectory:" + $skuName.InstallDirectory)
psDebugLog -level 1 -message ("ComputerName : " + $MSComputerName)
psDebugLog -level 1 -message ("ManagedEntityId : " + $managedEntityID)
psDebugLog -level 1 -message ("sourceID : " + $sourceID)
psDebugLog -level 1 -message ("DMSId, LogLevel, LogDirectory : " + $DMSId + ", " + $logLevel + ", " + $logDirectory)
psDebugLog -level 1 -message ("FMP Type" + $FMPType)
psDebugLog -level 1 -message ("FMP Host FQDN parameter (from override)" + $FMPHostFqdn)

#$sysinfo = Get-WmiObject -Class Win32_ComputerSystem
#$localFqdn = "{0}.{1}" -f $sysinfo.Name, $sysinfo.Domain
$sysinfo = Get-ItemProperty -Path "HKLM:\SOFTWARE\Dell Computer Corporation\Dell Management Pack Suites"
$localFqdn = $sysinfo.MSHostName
if( $localFqdn -eq $null -or $localFqdn.Length -eq 0 )
{
$sysinfo = [System.Net.Dns]::GetHostEntry([string]$env:computername)
$localFqdn = $sysinfo.HostName
}
psDebugLog -level 1 -message ("Current Management Server's local FQDN - " + $localFqdn + "-")

$EqualLogicRegistryKeyEntry = $null

if ($FMPType -eq "SuiteServer")
{
$ServerRegistryKeyEntry = GetServerVersion -KeyToFind "CurrentVersion"
}
elseif ($FMPType -eq "SuiteEqualLogic")
{
$EqualLogicRegistryKeyEntry = GetEqualLogicVersion -KeyToFind "CurrentVersion"
}

$oAPI = new-object -comObject "MOM.ScriptAPI"
$Discovery = $oAPI.CreateDiscoveryData(0, $sourceID, $managedEntityID)

#Special case where un-installation of EQL making Monitoring Feature instance remaining because Triggered Discovery is not running so to make triggered discovery run
#we are creating a EQL FMP object
$ServerRegistryKeyEntry = GetServerVersion -KeyToFind "CurrentVersion"
$EqualLogicRegistryKeyEntry = GetEqualLogicVersion -KeyToFind "CurrentVersion"
if($ServerRegistryKeyEntry -ne $null -and $EqualLogicRegistryKeyEntry -eq $null )
{
psDebugLog -level 1 -message ("Found Server Registry present and EqualLogic Registry not present")
$Instance = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.EqualLogic.SelectedHostMgmtServer']$")
$Instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $localFqdn)
$Instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Dell Feature Monitoring Host Emulator")
$Instance.AddProperty("$MPElement[Name='Dell.FeatureManagement.DMSInstallBase']/FMPEqualLogic$", "Not Selected")
$Instance.AddProperty("$MPElement[Name='Dell.FeatureManagement.DMSInstallBase']/SuiteEqualLogic$", "Not Installed")
$Discovery.AddInstance($Instance)
}

if($ServerRegistryKeyEntry -ne $null -and $FMPType -eq "SuiteServer")
{
#Found a Dell Management Pack Suite installation

if ($FMPHostFqdn -eq $localFqdn)
{
psDebugLog -level 1 -message ("FMPHostFqdn is equal to localFqdn, Current Management Server is selected as FMP Host ")
if ($FMPType -eq "SuiteServer")
{
psDebugLog -level 1 -message ("Dell Server Management Pack Suite installed on MS.")
$Instance = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.SelectedHostMgmtServer']$")
$Instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $localFqdn)
$Instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Dell Feature Monitoring Host Emulator")
$Instance.AddProperty("$MPElement[Name='Dell.FeatureManagement.DMSInstallBase']/FMPServer$", "Not Selected")
$Discovery.AddInstance($Instance)
psDebugLog -level 1 -message ("Discovered instance of selected Dell Management Suite Host Emulator - " + $localFqdn + " , added to SCOM")
CallPrimaryDiscoveryScript -Discovery $Discovery -SCOMEnv $scomenv
}
}
else
#FQDN not same as override
{
psDebugLog -level 1 -message ("FMPHostFQDN is not equal to the Local FQDN , so current management server is not selected as FMP Host ")
$Instance = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FMPDiscovery.Sink']$")
$Instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Dell Discovery Sink")
$Instance.AddProperty("$MPElement[Name='Dell.FMPDiscovery.Sink']/Name$","Dummy Object")
$Discovery.AddInstance($Instance)
}
}

elseif($EqualLogicRegistryKeyEntry -ne $null -and $FMPType -eq "SuiteEqualLogic" )
{
#Found a Dell EqualLogic Management Pack Suite installation
if ($FMPHostFqdn -eq $localFqdn)
{
psDebugLog -level 1 -message ("FMPHostFqdn is equal to localFqdn, Current Management Server is selected as FMP Host ")
psDebugLog -level 1 -message ("Dell Equal Management Pack Suite installed on MS.")
$Instance = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FeatureManagement.SelectedHostMgmtServer']$")
$Instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $localFqdn)
$Instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Dell Feature Monitoring Host Emulator")
$Instance.AddProperty("$MPElement[Name='Dell.FeatureManagement.DMSInstallBase']/FMPServer$", "Not Selected")
$Discovery.AddInstance($Instance)
psDebugLog -level 1 -message ("Populating the EqualLogic Monitoring Feature Instances")
CallEqlPrimaryDiscoveryScript -Discovery $Discovery -SCOMEnv $scomenv
}
else
#FQDN not same as override
{
psDebugLog -level 1 -message ("FMPHostFQDN is not equal to the Local FQDN , so current management server is not selected as FMP Host ")
$Instance = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FMPDiscovery.Sink']$")
$Instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Dell Discovery Sink")
$Instance.AddProperty("$MPElement[Name='Dell.FMPDiscovery.Sink']/Name$","Dummy Object")
$Discovery.AddInstance($Instance)
}
}
else
#No registry entries found
{
psDebugLog -level 1 -message ("Dell Management Pack Suites not installed.")
$Instance = $Discovery.CreateClassInstance("$MPElement[Name='Dell.FMPDiscovery.Sink']$")
$Instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Dell Discovery Sink")
$Instance.AddProperty("$MPElement[Name='Dell.FMPDiscovery.Sink']/Name$","Dummy Object")
$Discovery.AddInstance($Instance)
}

psDebugLog -level 1 -message ("End of " + $scriptname + " Discovery script ")
psDebugLog -level 1 -message "----------------------------------------------"
return $Discovery

</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>sourceID</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>managedEntityID</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>DMSId</Name>
<Value>$Config/DellManagementSuiteId$</Value>
</Parameter>
<Parameter>
<Name>logLevel</Name>
<Value>$Config/LogLevel$</Value>
</Parameter>
<Parameter>
<Name>logDirectory</Name>
<Value>DellFeatureMonitoring_Logs</Value>
</Parameter>
<Parameter>
<Name>FMPType</Name>
<Value>$Config/FMPType$</Value>
</Parameter>
<Parameter>
<Name>DMSType</Name>
<Value>$Config/DMSType$</Value>
</Parameter>
<Parameter>
<Name>FMPHostFqdn</Name>
<Value>$Config/FMPHostFqdn$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>