Posts: 2
Score: 0
Joined: 4/5/2005
From: USA
Status: offline
I used to use the old WINMGT interface to query a domain or even AD acting as a domain for things like all compuer objects, then do some routine on each one I found.
Using MS's new scripting center I can see script samples that get me a list of all the computers in an LDAP query.. and then a script to get particular values from a computer object.. but that script required teh FQDN of the LDAP object..
What I am trying to grasp is how or where to I find the possible properties that can be used in calls like "objRecordSet.Fields("Name")" in the sample below that will yield the FQDN that could be used in an additional query for things like the dns suffix search order of each machine found? I tried ADsPath, DistinguishedName, nohing yields anything other than the PC's short name.
Nick
-------Sample ------------------ On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection objCommand.CommandText = _ "Select Name, Location from 'LDAP://DC=corp,DC=dom' " _ & "Where objectClass='computer'" objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst
Do Until objRecordSet.EOF Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name")
Posts: 2
Score: 0
Joined: 4/5/2005
From: USA
Status: offline
OK, you have just turned on a light bulb that I was missing! I never made a correlation to the objRecordSet.Fields and the objCommand.CommandText... so I never had the DistingguishedName listed as an argument to collect, so my attempts at displaying the distiguished name always came up blank. Now they work! And tehre is an ADSI MMC snap in, eh? I will be grabbing that!!
What I can do now is use teh samples from the MS Script Center, and glue 1 or 2 together such that I can now loop through the tree and get all computer objects, and take the distiguished name field to feed to any other script segment that tells me things about each computer. My first task being to locate all machines that have bad suffix search orders statically set.