if we have a domain, is it possible to list all the computers connected to
that domain in WMI? if so - how?

Re: list of all computers? by Epoh

Epoh
Mon Oct 16 11:01:01 CDT 2006

If you are using AD try this:

'Start Script
Const ADS_SCOPE_SUBTREE = 2
DC = "MyDomain"
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Sort on") = "Name"

objCommand.CommandText = _
"SELECT Name FROM 'LDAP://dc=" & DC & ",dc=com' WHERE " _
& "objectCategory='computer'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("Name").Value
objRecordSet.MoveNext
Loop
'End Script


Re: list of all computers? by Richard

Richard
Mon Oct 16 11:51:14 CDT 2006

WMI can be used to connect to individual computers and retrieve information.
It cannot be used to discover what computers are out there. As noted, you
can use ADO to retrieve all computer objects in AD. If you want to generate
a list of all computers, then connect to each with WMI to retrieve
information, I have a sample VBScript linked here that does that:

http://www.rlmueller.net/Inventory.htm

As written, the script is limited to about 250 computers, because Excel can
only handle 255 columns. I have another version that reverses rows and
columns that can document many more. Reply if you are interested.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net