AK158820

Monitor_AK158820 (UnitMonitor)

Active Directory replication failures detected

Knowledge Base article:

External

http://go.microsoft.com/fwlink/?LinkId=211874

Element properties:

TargetMicrosoft.KnowledgeServices.Windows.Server.AD.ConnectionObject
Parent MonitorSystem.Health.ConfigurationState
CategoryAlert
EnabledTrue
Alert GenerateTrue
Alert SeverityError
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.KnowledgeServices.Library.PowerShellMonitorEx
RemotableTrue
AccessibilityPublic
Alert Message
One or more Active Directory replication failures has been detected
<Details>
<Content>Active Directory replication failures have been detected. Check the information collected below for more information about the Active Directory partition with the most recent failed replication attempt. See the Knowledge Base article for information on how to address this issue.
</Content>
<CollectedInformation>
<Info>
<Name>NamingContextDN</Name>
<Value>{1}</Value>
</Info>
<Info>
<Name>LastSyncResult</Name>
<Value>{2}</Value>
</Info>
<Info>
<Name>NumConsecutiveSyncFailures</Name>
<Value>{3}</Value>
</Info>
<Info>
<Name>SourceDsaSite</Name>
<Value>{4}</Value>
</Info>
<Info>
<Name>TimeOfLastSyncAttempt</Name>
<Value>{5}</Value>
</Info>
<Info>
<Name>TimeOfLastSyncSuccess</Name>
<Value>{6}</Value>
</Info>
<Info>
<Name>USNLastObjChangeSynced</Name>
<Value>{7}</Value>
</Info>
<Info>
<Name>Writeable</Name>
<Value>{8}</Value>
</Info>
<Info>
<Name>Other partitions with replication problems (if any)</Name>
<Value>{0}</Value>
</Info>
</CollectedInformation>
</Details>
RunAsDefault
CommentSupportTopic=TBD;VersionNumber=1.0.0.0;

Source Code:

<UnitMonitor ID="Monitor_AK158820" Comment="SupportTopic=TBD;VersionNumber=1.0.0.0;" Accessibility="Public" Enabled="true" Target="MicrosoftKnowledgeServicesWindowsServerADLibrary!Microsoft.KnowledgeServices.Windows.Server.AD.ConnectionObject" ParentMonitorID="Health!System.Health.ConfigurationState" Remotable="true" Priority="Normal" TypeID="KnowledgeServicesLibrary!Microsoft.KnowledgeServices.Library.PowerShellMonitorEx" ConfirmDelivery="true">
<Category>Alert</Category>
<AlertSettings AlertMessage="MonitorMessage850e5be701a64fc9861481ad60dc46c4">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Data/Context/Property[@Name='AllNamingContextDNs']$</AlertParameter1>
<AlertParameter2>$Data/Context/Property[@Name='NamingContextDN']$</AlertParameter2>
<AlertParameter3>$Data/Context/Property[@Name='LastSyncResult']$</AlertParameter3>
<AlertParameter4>$Data/Context/Property[@Name='NumConsecutiveSyncFailures']$</AlertParameter4>
<AlertParameter5>$Data/Context/Property[@Name='SourceDsaSite']$</AlertParameter5>
<AlertParameter6>$Data/Context/Property[@Name='TimeOfLastSyncAttempt']$</AlertParameter6>
<AlertParameter7>$Data/Context/Property[@Name='TimeOfLastSyncSuccess']$</AlertParameter7>
<AlertParameter8>$Data/Context/Property[@Name='USNLastObjChangeSynced']$</AlertParameter8>
<AlertParameter9>$Data/Context/Property[@Name='Writeable']$</AlertParameter9>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Error"/>
</OperationalStates>
<Configuration>
<ScriptName>AK158820.ps1</ScriptName>
<Parameters>
<Parameter>
<Name>ConnectionName</Name>
<Value>$Target/Property[Type="MicrosoftKnowledgeServicesWindowsServerADLibrary!Microsoft.KnowledgeServices.Windows.Server.AD.ConnectionObject"]/Name$</Value>
</Parameter>
</Parameters>
<ScriptBody><Script>


param($ConnectionName)

$ErrorActionPreference = "Stop"

# Set up the arguments
$scriptargs = new-object psobject
$scriptargs | add-member NoteProperty "ConnectionName" $ConnectionName

# Set up the output
$global:scriptoutput = new-object psobject
$scriptoutput | add-member NoteProperty "HasIssue" $false
$scriptoutput | add-member NoteProperty "AllNamingContextDNs" ""
$scriptoutput | add-member NoteProperty "NamingContextDN" ""
$scriptoutput | add-member NoteProperty "LastSyncResult" ""
$scriptoutput | add-member NoteProperty "NumConsecutiveSyncFailures" ""
$scriptoutput | add-member NoteProperty "SourceDsaSite" ""
$scriptoutput | add-member NoteProperty "TimeOfLastSyncAttempt" ""
$scriptoutput | add-member NoteProperty "TimeOfLastSyncSuccess" ""
$scriptoutput | add-member NoteProperty "USNLastObjChangeSynced" ""
$scriptoutput | add-member NoteProperty "Writeable" $false


Function GetReplicationStatus ([string] $SourceDsaCN, [array] $LastSyncResultToExclude = @(0)) {
Get-WmiObject -Class msad_replneighbor -namespace root\microsoftactivedirectory |
Where-Object {($LastSyncResultToExclude -notcontains $_.LastSyncResult) -and ($_.SourceDsaCN = $SourceDsaCN)} |
Sort-Object TimeOfLastSyncAttempt
}

function AdvisorRule($scriptargs, $scriptoutput)
{
$scriptoutput.HasIssue=$false

$ErrorNumber = 0

#ConnectionName argument comes in DOMAIN\COMPUTERNAME. We need only the COMPUTERNAME to compose the $SourceDsaCN
$SourceDsaCN = $ScriptArgs.ConnectionName.Split("\")[1]

# Below the list of error codes for LastSyncResult property on which this generic rule will not be fired in case of they are present on the system.
# We decided to exclude some of the LastSyncResult codes that are detected and managed by other rules.
# AK158843 -&gt; 8614
# AK158625 -&gt; 8606
$LastSyncResultToExclude = @(0, 8614, 8606, 5, 1753, 1256, 1127, -2146893022, 8524, 1256, 4396, 8453, 1722, 8452)

$replneighbor = GetReplicationStatus $SourceDsaCN $LastSyncResultToExclude

If ($replneighbor -ne $null)
{
$NamingContextDNs = ""
$NamingContextDNArray = @()
foreach ($neighbor in $replneighbor)
{
$ErrorNumber++

If ($ErrorNumber -eq 1)
{
$scriptoutput.NamingContextDN = $neighbor.NamingContextDN
$scriptoutput.LastSyncResult = $neighbor.LastSyncResult
$scriptoutput.NumConsecutiveSyncFailures = $neighbor.NumConsecutiveSyncFailures
$scriptoutput.SourceDsaSite = $neighbor.SourceDsaSite
$scriptoutput.TimeOfLastSyncAttempt = [management.managementDateTimeConverter]::ToDateTime($neighbor.TimeOfLastSyncAttempt).AddMinutes([System.TimeZoneInfo]::Local.BaseUtcOffset.TotalMinutes * -1)
$scriptoutput.TimeOfLastSyncSuccess = [management.managementDateTimeConverter]::ToDateTime($neighbor.TimeOfLastSyncSuccess).AddMinutes([System.TimeZoneInfo]::Local.BaseUtcOffset.TotalMinutes * -1)
$scriptoutput.USNLastObjChangeSynced = $neighbor.USNLastObjChangeSynced
$scriptoutput.Writeable = $neighbor.Writeable
}
else
{
$NamingContextDNArray += "(" + $neighbor.NamingContextDN + ")"
}
}

if ($ErrorNumber -gt 0)
{
$scriptoutput.AllNamingContextDNs = [string]::Join(", ", $NamingContextDNArray)
$scriptoutput.HasIssue = $true
}
}
}

AdvisorRule $scriptargs $scriptoutput

# set the output
$mom = new-object -comobject "MOM.ScriptAPI"
$bag = $mom.CreatePropertyBag()

if ($scriptoutput.HasIssue -ne $null)
{
$bag.AddValue("HasIssue", $scriptoutput.HasIssue)
}

if ($scriptoutput.AllNamingContextDNs -ne $null)
{
$bag.AddValue("AllNamingContextDNs", $scriptoutput.AllNamingContextDNs)
}

if ($scriptoutput.NamingContextDN -ne $null)
{
$bag.AddValue("NamingContextDN", $scriptoutput.NamingContextDN)
}

if ($scriptoutput.LastSyncResult -ne $null)
{
$bag.AddValue("LastSyncResult", $scriptoutput.LastSyncResult)
}

if ($scriptoutput.NumConsecutiveSyncFailures -ne $null)
{
$bag.AddValue("NumConsecutiveSyncFailures", $scriptoutput.NumConsecutiveSyncFailures)
}

if ($scriptoutput.SourceDsaSite -ne $null)
{
$bag.AddValue("SourceDsaSite", $scriptoutput.SourceDsaSite)
}

if ($scriptoutput.TimeOfLastSyncAttempt -ne $null)
{
$bag.AddValue("TimeOfLastSyncAttempt", $scriptoutput.TimeOfLastSyncAttempt)
}

if ($scriptoutput.TimeOfLastSyncSuccess -ne $null)
{
$bag.AddValue("TimeOfLastSyncSuccess", $scriptoutput.TimeOfLastSyncSuccess)
}

if ($scriptoutput.USNLastObjChangeSynced -ne $null)
{
$bag.AddValue("USNLastObjChangeSynced", $scriptoutput.USNLastObjChangeSynced)
}

if ($scriptoutput.Writeable -ne $null)
{
$bag.AddValue("Writeable", $scriptoutput.Writeable)
}

$bag

</Script></ScriptBody>
<SnapIns/>
<TimeoutSeconds>300</TimeoutSeconds>
<Schedule>86384</Schedule>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Boolean">Property[@Name='HasIssue']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Boolean">true</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<SuccessExpression>
<Not>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Boolean">Property[@Name='HasIssue']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Boolean">true</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</Not>
</SuccessExpression>
</Configuration>
</UnitMonitor>