AD Replication Monitor (PowerShell) Server 2008 - 2012

This template will test AD replication via PowerShell.  It basically pulls "repadmin/replsum/bydest data from the domain controllers".  If no replication errors are detected a statistic = 0 will be returned or condition = GREEN.  If replication errors are detected a statistic = 1 will result Meaning Condition = critical or RED.  This monitor can be executed on any machine in the target domain with an account that can execute PoSh scripts on the local machine.  This was how I first deployed the monitor as I had the monitor assigned to one of my polling engines.  The monitor can also be set up to run on a remote system (my current deployment) using WinRM.  Running remotely will require the Solarwinds service account to rights on the remote system, in the event the remote system is a Domain Controller Domain Admin privileges will be required. Running on a remote system is ideal for environments with multiple domains. 

  • I spent 10 minutes trying to get this working and then found there is now a built in PS command for Replication Failures, so I did a really quick script to check for failures using this new command.

    This seems to be working fine.

    # Checks Replication Against the DC IP

    $Replication = Get-ADReplicationFailure ${IP}

    # If in the response more than 1 failure is found, it will alert.

    IF ($Replication | Where-Object {$_.FailureCount -ge "2"}) {

        $Statistic = $Replication.FailureCount

        Write-Host "Message: More than 1 Replication Error Found";

        Write-Host "Statistic: $Statistic";

        Exit 1;

    }

    # If $Replication is found but no errors, then will report back good.

    ELSE {

        IF ($Replication) {

            Write-Host "Message: No errors found in replication";

            Write-Host "Statistic: 0";

            Exit 0;

        } ELSE {

            Write-Host "Message: No Replication Partner found";

            Write-Host "Statistic: 0";

            Exit 0;

        }

    }

  • The regex in this script does not seem to be working for me. I will see if I can fix it and update.