Link to home
Start Free TrialLog in
Avatar of seaninman
seaninmanFlag for United States of America

asked on

Update Functionality of a VB Script

I have the below script that I would like to add some king of progress bar and an output file that shows all the accounts it processes.  I was wondering if someone could provide some simple code to do this?
'On Error Resume Next

Set oContainer = GetObject("LDAP://OU=test,OU=test1,OU=Users,DC=test,DC=com")
Set oCanadaGrp = GetObject("LDAP://CN=APP_Canada_Assoc,OU=GO,OU=Applications,OU=Groups - Security,OU=Admin,DC=test,DC=com")
Set oUSAGrp = GetObject("LDAP://CN=APP_USA_Store_Assoc,OU=GO,OU=Applications,OU=Groups - Security,OU=Admin,DC=test,DC=com")
For Each object In oContainer
        Found = False
        If LCase(object.Class) = "user" Then
                If LCase(object.co) = "united states" Then 
                        For Each member In oUSAGrp.members
                                If LCase(member.ADSPath) = LCase(object.ADSPath) Then 
                                	Found = True
                                	Exit For
                                End If
                        Next
                        If Not Found Then oUSAGrp.Add(object.ADSPath)
                End If
                If LCase(object.co) = "canada" Then
                        For Each member In oCanadaGrp
                                If LCase(member.ADSPath) = LCase(object.ADSPath) Then
                                	Found = True
                                	Exit For
                                End If
                        Next
                        If Not Found Then oCanadaGrp.Add(object.ADSPath)
                End If
        End If
Next

Open in new window

Avatar of Justin Ellenbecker
Justin Ellenbecker
Flag of United States of America image

Unfortunately there is no progress bar available in VB Script that I know of.  VB.net would have a progress bar available.  As far as a file for the output I will add some lines and post the code back for you.
ASKER CERTIFIED SOLUTION
Avatar of Justin Ellenbecker
Justin Ellenbecker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To expand on the progress bar thing the reason is that it runs the command 1 line at a time and stores the information so if I remember right there would be no way to thread off a progress bar.  Also because your query is happening on the fly for the groups the only way to build something similar to progress bar would be to fully enumerate the AD group and then use the accounts total as an index to go off of.  Then you could build it in to pop up a box with percentages but again without being able to thread off the progress bar as a separate workload called from the main script the most you will get is a log file that shows the accounts processed.  You could as mentioned in my first post create a thread for the progress bar as soon you start the for loop since it would then enumerate the total number of users and you can increment the progress bar based on the current user it is on and gather a percentage there to feed at it.