if ($matchResults -ne $null)
{
switch ($matchResults)
{
"Primary SCP Info" {
$ENU_MESSAGE = $ENU_MESSAGE_BASE;
$ENU_MESSAGE += "Could not find " + "\" + $registryPath + "\" + "\n";
$ENU_MESSAGE += "The HealthService needs at least a primary management server to communicate.\n";
$ENU_MESSAGE += "This may indicate that the following:\n";
$ENU_MESSAGE += "\t* HealthService has not queried and cached the AD SCPs yet\n";
$ENU_MESSAGE += "\t* HealthService doesn't have access to any SCPs, yet is configured for AD Integration\n";
$ENU_MESSAGE += "Match results: " + $matchResults[1];
$oAPI.LogScriptEvent($SCRIPT_NAME, 6028, $EVENTLOG_WARNING_TYPE, $ENU_MESSAGE);
Exit 1;
break;
}
"Secondary SCP Info " {
Write ("\nCould not find \ $matchResults[1] \ Service DNS Name\ under \ $SecondarySCPInfoRootRegKey \");
Write ("\nThis is not a fatal error as the HealthService may not have any failovers.");
Write ("\nMatch results: " + $matchResults[1]);
break;
}
default {
throw("Unknown RegKey Type");
}
}
}
}
if (($EnableADIntegration) -and ($UseActiveDirectory))
{
$PrimarySCPInfo = SafeRegRead $PrimarySCPInfoRegValue "Service DNS Name"
$PrimarySCPInfo = $PrimarySCPInfo."Service DNS Name"
Write ("\nPrimary SCP Info value: " + $PrimarySCPInfo);
}
if (($EnableADIntegration) -and ($UseActiveDirectory))
{
# There can be many Secondary SCP Info reg keys. For RC1, just going to do 10
# In RC2 may change this to WMI StdRegProv so we can enumerate through the Secondary SCP Info Root key
# WshShell.RegRead() doesn't return objects.
for ($i = 0; $i -lt $MAX_FAILOVERS; $i++)
{
if ($PrimarySCPInfo -ne $null)
{
$regPath = $SecondarySCPInfoRootRegKey + $SecondarySCPInfoPrefix + ($i+1).toString();
$regValue = SafeRegRead $regPath "Service DNS Name"
$regValue = $regValue."Service DNS Name"
if ($regValue -ne $null)
{
# Verify Topology
# -- Bad Topo #1: 2 Primary relationships.
# This one can't happen since I only read one specific RegValue and create only 1 relationship instance
# Note that if there are ever any 2 Secondary TARGETs pointing to the same server, its already handled on the server side
# -- Bad Topo #2: Both Primary and Secondary TARGETs point to same DNS Name
if ($PrimarySCPInfo.toString().toLowerCase() -eq $regValue.toString().toLowerCase())
{
$ENU_MESSAGE = $ENU_MESSAGE_BASE
$ENU_MESSAGE += "Invalid topology detected.\n";
$ENU_MESSAGE += "\tRelationship Source (Agent) : " + $ComputerIdentity + "\n";
$ENU_MESSAGE += "\tRelationship Target (Primary SCP Info) : " + $PrimarySCPInfo.toString() + "\n";
$ENU_MESSAGE += "\tRelationship Target (Secondary SCP Info): " + $regValue.toString() + "\n\n";
$ENU_MESSAGE += "Ignoring cached Secondary SCP Info from: " + $regPath + "\n";
# Discovery data for Secondary failover communcation instances - Microsoft.SystemCenter.HealthServiceSecondaryCommunication
# Can be null since there may be no failovers configured at all
if ($SecondarySCPInfoRootRegKey -ne $null)
{
# Source of HealthServiceSecondaryCommunication relationship
$oHSSecondaryCommunicationSource = $oDiscovery.CreateClassInstance("$MPElement[Name='SCLibrary!Microsoft.SystemCenter.HealthService']$");
$oHSSecondaryCommunicationSource.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $ComputerIdentity);
# Target of HealthServiceSecondaryCommunication relationship
$oHSSecondaryCommunicationTarget;
foreach ($key in $SecondarySCPInfoRegKeys)
{
if ($SecondarySCPInfoRegKeys[$key] -ne $null)
{
$oHSSecondaryCommunicationTarget = $oDiscovery.CreateClassInstance("$MPElement[Name='SCLibrary!Microsoft.SystemCenter.HealthService']$");
$oHSSecondaryCommunicationTarget.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $SecondarySCPInfoRegKeys[$key].toString());