• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

This script does exactly what I need except for throwing up the OK button which must be clicked for each user. Is there any way to disable that pop-up?

This script does exactly what I need except for throwing up the OK button which  must be clicked for each user in the OU. Is there any way to disable that pop-up? It would also be nice if this only stuffed user accounts and contacts but avoided adding OUs or other groups within the OU.
On Error Resume Next '<<< add this line to skip errors
Set objOU = GetObject("LDAP://OU=SomeOU,dc=domain,dc=local")
Set objGroup = GetObject("LDAP://CN=GroupNameOU=SomeOU,dc=domain,dc=local")
 
For Each objUser in objOU
    strUser=objuser.AdsPath
    objGroup.Add strUser
    msgbox "Added " & strUser
Next

Open in new window

0
hcca
Asked:
hcca
1 Solution
 
ValleyENTCommented:
I am assuming you are being prompted like 100 times with a msgbox, if this is correct then you simply need to remove the "msgbox "Added " & strUser" in your code. It will do as you need, but just wont notify you each time.
0
 
Dhiraj MuthaCommented:
Try this and check it out.
On Error Resume Next '<<< add this line to skip errors
Set objOU = GetObject("LDAP://OU=SomeOU,dc=domain,dc=local")
Set objGroup = GetObject("LDAP://CN=GroupNameOU=SomeOU,dc=domain,dc=local")
 
For Each objUser in objOU
    strUser=objuser.AdsPath
    objGroup.Add strUser
    'msgbox "Added " & strUser
Next

Open in new window

0
 
hccaAuthor Commented:
Thanks so much for the quick reply to what, as it turned out, was a simple question. Never-the-less, I won't have to be messing with that problem tomorrow morning when I actually implement this. Both answers were correct but you got there first. Thanks again.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Tackle projects and never again get stuck behind a technical roadblock.
Join Now