Monitoring Active Directory (AD) Replication in Windows Server 2008 R2

Solution 1:

Looking through the Directory Services Perfmon counters I don't see anything that seems to be exactly what I want.

I happen to use a monitoring system that supports powershell (Orion), so I wrote this up really quick and am going to see how it works for my needs:

#PS Script to Monitor Seconds since Last Successful AD Sync (By taking the longest (max) of any partition 
#KMB 11/22/2011 

#http://archive.msdn.microsoft.com/RepPSAdmin/Release/ProjectReleases.aspx?ReleaseId=5267
import-module -name RepPSAdmin

$hostname = $env:COMPUTERNAME

#PS C:\Windows\system32> Get-ADServerReplicationStatus -ServerName $hostname -SourceServer | Get-Member -memberType *property

$now = Get-Date
$latest = New-Timespan -start $now -end $now
Get-ADServerReplicationStatus -ServerName $hostname -SourceServer | foreach-object { 
    #Write-Host $_.LastSuccessfulSync}
    $temp = $now - $_.LastSuccessfulSync
    #Write-Host $_.LastSuccessfulSync :: $temp :: $temp.TotalSeconds
    if ($temp.TotalSeconds -gt $latest.TotalSeconds) {
        $latest = $temp
    }
}
Write-Host $latest.TotalSeconds

Disclaimer -- this script is still a work and progress and I don't really know powershell :-P