I have a powershell script that runs everyday. Today it failed because the domain controller i was using became unavailable. Before I can continue with the rest of the script i want to make sure I can connect to a available DC.
$LdapServer = "DC874.model.com"
Get-ADDomainController -server $ldapserver
Today the above code threw an error "unable to contact the server". I can have $ldapserver populated with multiple DC but I am not sure how to get an available DC so rest of the code dont fail. so if the first dc server listed is failed it will go to next dc server. if next dc server is good then determining available dc can stop and update $activeLDAP with the available DC. Is it possible?