Public/Domain/Get-ADReplicationInfo.ps1

function Get-ADReplicationInfo {

    try {
        Write-Log "Retrieving replication topology for domain..." -Level Info
        
        # Get replication connections
        $replicationConnections = Get-ADReplicationConnection -Filter * | 
        ForEach-Object {
            [PSCustomObject]@{
                FromServer    = $_.ReplicateFromDirectoryServer
                ToServer      = $_.ReplicateToDirectoryServer
                Schedule      = $_.ReplicationSchedule
                Options       = $_.Options
                AutoGenerated = $_.AutoGenerated
            }
        }
        
        # Get replication site links
        $siteLinks = Get-ADReplicationSiteLink -Filter * |
        ForEach-Object {
            [PSCustomObject]@{
                Name                 = $_.Name
                Cost                 = $_.Cost
                ReplicationFrequency = $_.ReplicationFrequencyInMinutes
                Sites                = $_.Sites
            }
        }
        
        # # Get replication status
        # $replicationStatus = Get-ADReplicationPartnerMetadata -Target $DomainName -Scope Domain |
        # ForEach-Object {
        # [PSCustomObject]@{
        # Partner = $_.Partner
        # LastReplicationAttempt = $_.LastReplicationAttempt
        # LastReplicationResult = $_.LastReplicationResult
        # LastReplicationSuccess = $_.LastReplicationSuccess
        # }
        # }
        
        $replicationInfo = [PSCustomObject]@{
            Connections = $replicationConnections
            SiteLinks   = $siteLinks
            # Status = $replicationStatus
        }

        return $replicationInfo
    }
    catch {
        Write-Log "Error retrieving replication topology: $($_.Exception.Message)" -Level Error
        return $null
    }
}