<#
DFSR & Replication Health Check
Run this on a Domain Controller (PowerShell as Administrator)
#>
$PartnerDCs = (Get-ADDomainController -Filter * | Where-Object { $_.Name -ne $env:COMPUTERNAME }).Hostname
Write-Host "==== DFSR Service Check on $env:COMPUTERNAME ====" -ForegroundColor Cyan
Get-Service DFSR | Format-Table Name, Status, StartType
Write-Host "`n==== SYSVOL & NETLOGON Shares ====" -ForegroundColor Cyan
Get-SmbShare | Where-Object { $_.Name -in @("SYSVOL","NETLOGON") } | Format-Table Name, Path, Description
Write-Host "`n==== Firewall & RPC Port Tests ====" -ForegroundColor Cyan
foreach ($dc in $PartnerDCs) {
Write-Host "`nTesting connectivity to $dc ..." -ForegroundColor Yellow
Test-NetConnection -ComputerName $dc -Port 135 # RPC Endpoint Mapper
Test-NetConnection -ComputerName $dc -Port 445 # SMB
Test-NetConnection -ComputerName $dc -Port 5722 # DFSR
}
Write-Host "`n==== Replication Summary ====" -ForegroundColor Cyan
repadmin /replsummary
Write-Host "`n==== Detailed Replication Status ====" -ForegroundColor Cyan
repadmin /showrepl $env:COMPUTERNAME
Write-Host "`n==== DFSR AD Poll (forces DC to check AD config) ====" -ForegroundColor Cyan
dfsrdiag pollad