Apronk,
I hate asking more questions but this is what I have. I have a DomainAD.cmd file with kix32 DomainAD.kix (name of file below) to run this
and nothing outputs to screen? I even have a pause at end of my cmd file.
What did I do wrong? I am runnin this on a file server with domain rights?
Is the order of my ldap query right (the parameters?) I use funny as a fake domain name for security but this is how it goes:
the levels are funny.priv then funny ou, then branch name then Computers final OU with the list of computers inside? is that right order?
 Code:
 

Dim $Branch1, $Branch2, $Branch3, $Branch4
;fnLDAPQuery(WHAT, Optional FROM, Optional FILTER, Optional ORDER BY, Optional SCOPE, Optional USER, Optional PASSWORD)

$Branch1 = fnLDAPQuery('SRV-DC1','ou=funny,ou=ForthAve,ou=Computers,dc=microsoft,dc=funny,dc=priv')
$Branch2 = fnLDAPQuery('SRV-DC1','ou=funny,ou=EighthSt,ou=Computers,dc=microsoft,dc=funny,dc=priv')
$Branch3 = fnLDAPQuery('SRV-DC1','ou=funny,ou=PostRd,ou=Computers,dc=microsoft,dc=funny,dc=priv')
$Branch4 = fnLDAPQuery('SRV-DC1','ou=funny,ou=ParkDr,ou=Computers,dc=microsoft,dc=funny,dc=priv')
;*****************************Display Test ****************************************************
For Each $x in $Branch1
  ;Display array list as test
  ? $x
Next

For Each $x in $Branch2
  ;Display array list as test
  ? $x
Next

For Each $x in $Branch3
  ;Display array list as test
  ? $x
Next

For Each $x in $Branch4
  ;Display array list as test
  ? $x
Next

;***********************LDAP Function ******************************************************

Function fnLDAPQuery($What,Optional $From,Optional $Filter,Optional $OrderBy,Optional $Scope,
    Optional $User,Optional $Pswd)
    
    Dim $oCon,$oCMD,$oRS,$sQ,$aR,$C,$R
    
    $sQ="<"+Iif($From="","LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext"),
        $From)+">;"+$Filter+";"+Iif(VarType($What)>8192,Join($What,','),$What)+";"+
        Iif($Scope<>"base" AND $Scope<>"onelevel","subtree",$Scope)
    
    $oCon=CreateObject("ADODB.Connection")
    $oCon.Provider="ADsDSOObject"
    $oCon.Properties("Encrypt Password").Value=1
    $oCon.Properties("ADSI Flag").Value=1
    If $User AND $Pswd
        $oCon.Properties("User ID").Value=$User
        $oCon.Properties("Password").Value=$Pswd
    EndIf
    $oCon.Open("Active Directory Provider")
     
    $oCMD=CreateObject("ADODB.Command")
    $oCMD.ActiveConnection=$oCon
    $oCMD.CommandText=$sQ
    $oCMD.Properties("Page Size").Value=1000
    $oCMD.Properties("Timeout").Value=30
    $oCMD.Properties("Cache Results").Value=0
    
    If InStr($OrderBy,"distinguishedName")
        $oRS=CreateObject("ADODB.Recordset")
        $oRS.CursorLocation=3
        $oRS.Sort=$OrderBy
        $oRS.Open($sQ,$oCon,0,1,1)
    Else
        If $OrderBy
            $oCMD.Properties("Sort On").Value=$OrderBy
        EndIf
        $oRS=$oCMD.Execute
    EndIf
    If @ERROR Exit @ERROR EndIf
    If $oRS.BOF AND $oRS.EOF Exit @ERROR EndIf
    
    $aR = $oRS.GetRows()
    Dim $aFR[Ubound($aR,2),Ubound($aR,1)]
    For $R=0 to Ubound($aR,2)
        For $C=0 to Ubound($aR,1)
            $aFR[$R,$C]=$aR[$C,$R]
        Next
    Next
    
    $fnLDAPQuery=$aFR
EndFunction

_________________________
Robert
A+, CCNA, MCP
Network Admin
Credit Union Wisconsin