IanN1990 Posted September 3, 2016 Share Posted September 3, 2016 (edited) Hi, I have a issue at the moment that some of my domain controller go down and that causes big delays in my script. Is there any way of checking a domains status / availability before attempting to connect or if not is there any way to set a time-out when opening a connection (similar to _ieLoadwait timout)? Ian Edited September 3, 2016 by IanN1990 Link to comment Share on other sites More sharing options...
water Posted September 3, 2016 Share Posted September 3, 2016 _AD_ListDomainControllers returns a list of all DCs. Do a ping and you will - at least - know if the server itself is up. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
IanN1990 Posted September 3, 2016 Author Share Posted September 3, 2016 As your the creator of the most useful AD UDF I will close this as solved Link to comment Share on other sites More sharing options...
water Posted September 3, 2016 Share Posted September 3, 2016 Thanks My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
IanN1990 Posted September 3, 2016 Author Share Posted September 3, 2016 (edited) As your the creator, whats your honest view on this code. #include "ad.au3" ConsoleWrite(@Crlf & CheckFastestADConnection()) Func CheckFastestADConnection() Dim $FastestADConnection = 10000, $FastestConnection="" _AD_Open() $ADDomainArray = _AD_ListDomainControllers() _AD_close() For $i=1 to ubound($ADDomainArray)-1 $Ping = Ping($ADDomainArray[$i][2], 10) If $Ping < 10 Then $ADConnectionTest = TimerInit() _AD_Open("", "", "", $ADDomainArray[$i][2], "") _AD_Close() $TimerDiff = Timerdiff($ADConnectionTest) ConsoleWrite($ADDomainArray[$i][2] & " " & $TimerDiff & @CRLF) If $FastestADConnection > $TimerDiff then $FastestADConnection = $TimerDiff $FastestConnection = $ADDomainArray[$i][2] EndIf EndIf Next Return $FastestConnection EndFunc 1. Connects to AD using local details 2. Gets a List of all the Domain Controllers 3. Pings each controller if its less < 10 then controller is online 4. Open / Close connection, recording time to complete this 5. Compares against last controller timer, lowest gets stored. Is this a good way to find out which controller is the fastest? Ian Edited September 3, 2016 by IanN1990 Link to comment Share on other sites More sharing options...
water Posted September 3, 2016 Share Posted September 3, 2016 How many DCs are we talking about? IIRC when connecting to a domain Windows selects the best/fastest DC if you do not specify one. So I think just calling _AD_Open() should give you the best result. Maybe this PS helps: https://blogs.msdn.microsoft.com/javaller/2013/07/29/powershell-one-liner-for-finding-lowest-latency-domain-controller/ My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Developers Jos Posted September 3, 2016 Developers Share Posted September 3, 2016 (edited) A ping to just the domainname should get you are reply from the "nearest" DC if I remember correctly. Jos Edited September 3, 2016 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
IanN1990 Posted September 3, 2016 Author Share Posted September 3, 2016 I have 8 domain controllers, using the ping command i get a response of either 1 or 5 Link to comment Share on other sites More sharing options...
Developers Jos Posted September 3, 2016 Developers Share Posted September 3, 2016 .. and they are the "nearest"? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now