Jump to content

Recommended Posts

Posted (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 by IanN1990
Posted

_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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Thanks :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (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 by IanN1990
Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...