Click to See Complete Forum and Search --> : Windows VBScript programming ...


slavik
06-13-2007, 03:46 PM
Does anyone know where I can get good documentation on the ADSI providers that are used in VBScript?

(Something like WMI Object browser, but for ADSI).

I've looked through MSDN but couldn't find anything.

slavik
06-13-2007, 03:58 PM
EDIT: Different problem, but did not want to start a new thread.

So far I have this piece of VBScript code to get the computer name


Set objWMIService = GetObject("winmgmts://./root/cimv2")
Set objComputerSystem = _
objWMIService.ExecQuery("select name from Win32_ComputerSystem")
For Each objIterator In objComputerSystem
GetSystemName = objIterator.Name
Next


My understanding is that the query returns a collection of items, what is the simplest way to turn this collection into an array?

richardginn
06-14-2007, 09:07 AM
You are going to have to dim some array with like 50 items in it or how many you think are going to need.

Then under the GetSystemName = objIterator.Name line of code you will have some code that will put some info into the array. Then one line of code that will move over one position in the array.

slavik
06-14-2007, 01:43 PM
so far, I just ReDim Preserve the array. I think that there is a way to get the count of the items ... going to look into it

Strogian
06-15-2007, 11:53 PM
Well since it is a SWbemObjectSet, you can always use the .Count property, which iterates through the entire collection and returns how many there are. (Not efficient.)

http://msdn2.microsoft.com/En-US/library/aa393762.aspx

But shouldn't it only return one computer name anyway? Or are you just thinking in general, not for that particular query?

I don't know about your ADSI providers question though. I know ADSIEdit is the tool to look at AD data, but I've never done VBScript work with it, so I don't know exactly what an ADSI provider is.