Jump to content
Sign in to follow this  
JRSmile

Domain Connection Check

Recommended Posts

JRSmile

I wrote a little script that checks all your domaincontrollers if they can ping each other,

unfortunately it only works on 2k3/2k8 servers and xp machines (didn't test with vista)...:

#include <array.au3>

if Not IsAdmin() Then; this is to check if the script has the rights to use the wmi service on the servers, could not work in your domain.
    RunAs("DOMAINADMIN", "DOMAIN", "DOMAINADMINPASS",0, @ScriptFullPath, @ScriptDir)
    Exit
EndIf


Dim $servers = get_dcs()

$count = (($servers[0]^)2-$servers[0])

ToolTip("Will check " & $count& " connections.",0,0)
Sleep(1000)

Dim $res[UBound($servers)][UBound($servers)]
$pos = 0
$checked = ""
For $x = 1 to $servers[0]
    $res[$x][0] = $servers[$x]
    $res[0][$x] = $servers[$x]
    For $y = 1 to $servers[0]
        $pos += 1
        ToolTip($checked & @CRLF & "Checking connection between: " & $servers[$x] & " and " & $servers[$y] & " [" &$pos & "/" & $count & "]", 0,0)
        if $servers[$x] = $servers[$y] Then
            $res[$x][$y] = "X"
        Else
            $res[$x][$y] = WMI_Ping($servers[$x], $servers[$y])
        EndIf
        $checked = "Checked connection between: " & $servers[$x] & " and " & $servers[$y] & " ==> " & $res[$x][$y] & " [" &$pos & "/" & $count & "]"
    Next
Next

_ArrayDisplay($res)


Func WMI_Ping($src, $dest)
    $ObjWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $src & "\root\cimv2")
    if not IsObj($ObjWMI) then Return SetError(1,0,False)
    $ColPingedComputer = $ObjWMI.ExecQuery("Select * from Win32_PingStatus" & " Where Address = '"&$dest&"'")
    For $ObjComputer In $ColPingedComputer
        If $ObjComputer.StatusCode = 0 Then
            Return True
        Else
            Return False
        EndIf
    Next
EndFunc  ;==>WMI_Ping

Func get_dcs()
    $objRootDSE = ObjGet("LDAP://RootDSE")
    $strConfigurationNC = $objRootDSE.Get("configurationNamingContext")
    $objConnection = ObjCreate("ADODB.Connection")
    $objCommand = ObjCreate("ADODB.Command")
    $objConnection.Provider = "ADsDSOObject"
    $objConnection.Open("Active Directory Provider")
    $objCommand.ActiveConnection = $objConnection
    $objCommand.Properties("Page Size") = 1000
    $objCommand.Properties("Searchscope") = 2
    $objCommand.CommandText = "SELECT ADsPath FROM 'LDAP://" & $strConfigurationNC & "' WHERE objectClass='nTDSDSA'"
    $objRecordSet = $objCommand.Execute

    $objRecordSet.MoveLast
    Local $res[$objRecordSet.RecordCount + 1]
    $res[0] = $objRecordSet.RecordCount

    $objRecordSet.MoveFirst
    Local $i = 0
    While Not $objRecordSet.EOF
        $i += 1
        $ads = $objRecordSet.Fields("ADsPath").Value
        $1 = ObjGet($ads)
        $objParent = ObjGet($1.Parent)
        $res[$i] = $objParent.CN
        $objRecordSet.MoveNext
    WEnd    
    Return $res
EndFunc  ;==>get_dcs

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

Share this post


Link to post
Share on other sites
ptrex

Share this post


Link to post
Share on other sites
JRSmile

thanks for this, got a faulty in my math part of brain ...


$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.