VBScript to echo entries in an array in a single message box.

Hi everyone,

Here's the situation:
My VBScript calls all user names up from a specific ou on my server. It places all of these in an array.  I need to be able to echo all entries in this array to a single message box.

Here's what works so far:

Dim UsersInOU(500)
Set objOU = GetObject("LDAP://" & UserOUPath)
i = 0
objOU.Filter = Array("user")
      For Each objUser In objOU
            UsersInOU(i) = objUser.Name
            i = i + 1
            X = i
      Next
For Y = 0 To X
wscript.echo Y  & " - " & UsersInOu(Y) & Vbcr
Y = Y + 1
Next

2 problems occur:  One- it echoes in increments of 2.. (0,2,4,6,8... ) skipping all odd numbers and it puts each in it's own pop up box.  I need it to show up as a list so that a user can then select the # that matches the user to work on and we can't be skipping every second entry either.  

Can anyone help?
LVL 2
RanidaeAsked:
Who is Participating?
 
kapesConnect With a Mentor Commented:
Dim UsersInOU(500)
Set objOU = GetObject("LDAP://" & UserOUPath)
i = 0
objOU.Filter = Array("user")
     For Each objUser In objOU
          UsersInOU(i) = objUser.Name
          i = i + 1
          X = i
     Next
Dim strTemp : strTemp = ""

For Y = 0 To X
strTemp =  strTemp & Y  & " - " & UsersInOu(Y) & Vbcr
Next
wscript.echo strTemp
0
 
RanidaeAuthor Commented:
Thanks so Much Kapes!!!!!!
0
 
RanidaeAuthor Commented:
Kapes... if you get this... what are the odds of having the script echo the UsersInOu in columns, max of 20 per column, cuz when there are more than fit on the screen, it doesn't show them all.
0
 
kapesCommented:
it would be bit complex to put it in vertical column...
I can give you in horizontal column of 5...


For Y = 0 To X
if (Y mod 5) = 0 then
strTemp =  strTemp & Y  & " - " & UsersInOu(Y) & Vbcrlf
else
strTemp =  strTemp & Y  & " - " & UsersInOu(Y) & " " 
end if
Next
wscript.echo strTemp
0
 
RanidaeAuthor Commented:
WHAT IF
instead of wscript.echo I used:

UserID = inputbox("These are the users in the selected group" & strTemp & "What user requires management? (Enter User # or click N to see next screen)","Users")

Have it display 30 names at a time

Then if the user clicks N... it does the same with the next 30 so on so forth until all names have been displayed or user has selected one?

I'm only getting 48 users outputed with what you just now posted and in some of the OUs there are 150 users.

Thanks for your time on this.... it is hugely apreciated.
0
All Courses

From novice to tech pro — start learning today.