Click here to Skip to main content
14,366,974 members

List All Computers in a Domain the Quick Way!

Rate this:
4.00 (2 votes)
Please Sign up or sign in to vote.
4.00 (2 votes)
22 Mar 2010CPOL
How to list all computers in a domain the quick way

This is in conjunction with my work here where I need to list all websites in a server, now I need to list all servers and what's the quick way of doing it? Again scripting in VBS.

Here is how I’ve done it:

const oFileName ="AllComputers.csv"
set oCmd = createobject("ADODB.Command")
set oConn = createobject("ADODB.Connection")
set oRS = createobject("ADODB.Recordset")

oConn.open "Provider=ADsDSOObject;"
oCmd.ActiveConnection = oConn

set oRoot = GetObject("LDAP://RootDSE")

oCmd.CommandText = "<LDAP://" & oRoot.Get("defaultNamingContext")  
		& ">;(objectCategory=Computer);" & _
          	"name, distinguishedName, operatingsystem, 
		operatingsystemservicepack, operatingsystemversion;subtree"
oCmd.Properties("page size")=1000

set oRS = oCmd.Execute
set oFSO = CreateObject("Scripting.FileSystemObject")
set oCSV = oFSO.CreateTextFile(oFileName)

sQuotations = """"

while oRS.EOF <> true and oRS.BOF <> true
    oCSV.writeline(sQuotations & oRS("name") & sQuotations & "," & _
    sQuotations & oRS("distinguishedName") & sQuotations & "," &  _
    sQuotations & oRS("operatingsystem") & sQuotations & "," & _
    sQuotations & oRS("operatingsystemservicepack") & sQuotations & "," & _
    sQuotations & oRS("operatingsystemversion") & sQuotations)
    oRS.MoveNext
wend

oCSV.Close
oConn.close

wscript.echo "Done!"

http://anyrest.wordpress.com/2010/02/10/how-to-list-all-websites-in-iis/

Image 1 Image 2 Image 3 Image 4 Image 5 Image 6

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Raymund Macaalay
Technical Lead
New Zealand New Zealand
http://nz.linkedin.com/in/macaalay
http://macaalay.com/

Comments and Discussions

 
GeneralMy vote of 3 Pin
tonymon98765420-Sep-10 22:57
membertonymon98765420-Sep-10 22:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Technical Blog
Posted 22 Mar 2010

Tagged as

Stats

10.2K views
4 bookmarked