set strRootDSE = GetObject ("LDAP://rootDSE") wscript.echo "Loading Domains at LDAP://CN=Partitions," & strRootDSE.get ("configurationNamingContext") set opartition = GetObject("LDAP://CN=Partitions," & strRootDSE.get ("configurationNamingContext")) for each oDomain in opartition if oDomain.NetBIOSname = "" then wscript.echo "Skip Domain: " & oDomain.dnsroot else wscript.echo "Processing Domain: " & oDomain.dnsroot call ParseDomain(oDomain.dnsroot) end if next sub ParseDomain(strdomainname) wscript.echo "Querying AD für Objects at Domain:" & strdomainname Set oConnection = CreateObject("ADODB.Connection") Set oRecordset = CreateObject("ADODB.Recordset") Set oCommand = CreateObject("ADODB.Command") oConnection.Provider = "ADsDSOObject" 'The ADSI OLE-DB provider oConnection.Open "ADs Provider" oCommand.ActiveConnection = oConnection oCommand.Properties("Page Size") = 100 oCommand.CommandText = ";" & _ "(mailnickname=*);" & _ "distinguishedName,ObjectClass,displayName,mail" & _ ";subtree" Set oRecordset = oCommand.Execute wscript.echo "Done Total Records found:" & oRecordset.recordcount do until oRecordset.EOF wscript.echo "distinguishedName:" & oRecordset.Fields("distinguishedName") wscript.echo "displayName :" & oRecordset.Fields("displayName") wscript.echo "Mail :" & oRecordset.Fields("mail") oRecordset.MoveNext loop end sub