Use DcDiag.exe to test every DC on the current Domain

  $dom = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()

foreach ($dc in $dom.DomainControllers){
    if (Test-Connection $dc -count 1 -Quiet){
        dcdiag /s:$dc /f:C:\Users\<username>\Desktop\$dc.txt
    }
    else {
        write-host “Server $dc is Offline” -BackgroundColor red
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *