You need the Distinguished Names of the OU and the group.
Save the below script as ScriptName.vbs
'Following script will add Security Group “TestGroup” to the OU Named “MyOU”
'Created by Ram http://www.askmewindows.in/
' Created Date :10/25/09
' Bind to OU object using Distinguished Name.
Set objOU = GetObject("LDAP://ou=MyOU,dc=MyDomain,dc=com"
' Bind to group object using Distinguished Name.
Set objGroup = GetObject("LDAP://cn=Test Group,ou=MyOU,dc=MyDomain,dc=com")
' Filter on user objects in OU.
objOU.Filter = Array("user")
' Enumerate users in OU.
For Each objUser In objGroup
' Check if user already a member of the group.
If (objGroup.IsMember(objUser.AdsPath) = False) Then
' Add user to the group.
objGroup.Add(objUser.AdsPath)
End If
Next
Msgbox “Completed”
1 comment:
Useful script, thanks
Post a Comment