Solved

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

Posted on 2004-10-29
308 Views
Last Modified: 2010-04-14
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?
0
Question by:Ranidae
    5 Comments
     
    LVL 6

    Accepted Solution

    by:
    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
     
    LVL 2

    Author Comment

    by:Ranidae
    Thanks so Much Kapes!!!!!!
    0
     
    LVL 2

    Author Comment

    by:Ranidae
    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
     
    LVL 6

    Expert Comment

    by:kapes
    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
     
    LVL 2

    Author Comment

    by:Ranidae
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    IT Security CISA, CISSP & CISM Certification

    Master the advanced techniques required to protect network resources from external threats with the IT Cyber Security bundle. Built around industry best-practice guidelines, the IT Cyber Security bundle consists of three in-depth courses.

    NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
    Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    This video discusses moving either the default database or any database to a new volume.

    877 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now