List all computers in a domain

Home Forums Scripting General Scripting List all computers in a domain

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    JDMils
    Member
    #126347

    I have the following script which I can’t get working:

    Quote:
    const FileName =”domaincomputers.csv”
    set cmd = createobject(“ADODB.Command”)
    set cn = createobject(“ADODB.Connection”)
    set rs = createobject(“ADODB.Recordset”)

    cn.open “Provider=ADsDSOObject;”
    cmd.activeconnection = cn

    set objRoot = getobject(“LDAP://v.com.au/cn=Computers,dc=voyager,dc=com,dc=au”) ‘ RootDSE

    cmd.commandtext = “;(objectCategory=Computer);” & _
    “name,operatingsystem,operatingsystemservicepack, operatingsystemversion;subtree”
    ‘**** Bypass 1000 record limitation ****
    cmd.properties(“page size”)=1

    set rs = cmd.execute
    set objFSO = createobject(“Scripting.FileSystemObject”)
    set objCSV = objFSO.createtextfile(FileName)

    q = “”””

    while rs.eof <> true and rs.bof <> true
    objcsv.writeline(q & rs(“name”) & q & “,” & q & rs(“operatingsystem”) & q & _
    “,” & q & rs(“operatingsystemservicepack”) & _
    q & “,” & q & rs(“operatingsystemversion”) & q)
    rs.movenext
    wend

    objCSV.Close
    cn.close

    wscript.echo “Finished”

    I get an error on line:
    set objRoot = Getobject(“LDAP://v.com.au/cn=Computers,dc=voyager,dc=com,dc=au”)

    The error is:
    Line 11
    Char 1
    The directory property cannot be found in the cache.
    Code 8000500D
    Source Active Directory

    As a test, my computer’s distinguished name is (from a working script):

    CN=JULIAN,CN=COMPUTERS,DC=V,DC=COM,DC=AU

    I’m running this script from my WinXP workstation. Thanks.

    PS. My next step is for the script to ask for the domain to query via an input box.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.