Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding Computer names

Status
Not open for further replies.

chxpty

MIS
May 19, 2005
7
US
I need to find all the computer names in the network. I am not really sure how to do this. please help.
 
Code:
'==========================================================================
'
' NAME: CreateWSList.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 3/18/2004
'
' COMMENT: <comment>
'
'==========================================================================

Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objDomain = getObject("LDAP://rootDse")
Domain = objDomain.Get("defaultNamingContext")
LDPATH = Chr(39) & "LDAP://" & Domain & Chr(39)


Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
    "Select Name, Location from " & LDPATH _
        & "where objectClass='computer'"  
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30 
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
objCommand.Properties("Cache Results") = False 
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
    report = report & objRecordSet.Fields("Name").Value & vbCrLf
    objRecordSet.MoveNext
Loop


Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.CreateTextFile ("wslist.txt", ForWriting)
ts.write report
ts.close
MsgBox "Done"

I hope you find this post helpful.

Regards,

Mark
 
that was very helpful now my next question is how do you find which user is logged in to what computer.
 
thread329-1063598

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top