AK158625

Monitor_AK158625 (UnitMonitor)

Lingering objects have been detected

Knowledge Base article:

External

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

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
Lingering objects have been detected
<Details>
<Content>Replication status 8606 was detected. This status indicates that a source domain controller sent an update to an object that exists on the source domain controller but that has been deleted by the destination domain controller. Long-term replication failures are one cause of lingering objects. 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 more 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.1.0;

Source Code:

<UnitMonitor ID="Monitor_AK158625" Comment="SupportTopic=TBD;VersionNumber=1.0.1.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="MonitorMessage6f1b0f83a38942178eff0c3293b3f50b">
<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>AK158625.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, [int] $LastSyncResultToQuery) {
Get-WmiObject -Class msad_replneighbor -namespace root\microsoftactivedirectory |
Where-Object {($_.LastSyncResult -eq $LastSyncResultToQuery) -and ($_.SourceDsaCN -eq $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]

$LastSyncResultToQuery = 8606

$replneighbor = GetReplicationStatus $SourceDsaCN $LastSyncResultToQuery

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>