Link to home
Start Free TrialLog in
Avatar of jskfan
jskfanFlag for Cyprus

asked on

a SCRIPT to add group members to another group

I have created a new users group, and already have other users groups that have members inside.

I would like to have a script that adds the members of existing groups to the new group.

Thanks
SOLUTION
Avatar of Chris Staunton
Chris Staunton
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
ASKER CERTIFIED SOLUTION
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
Avatar of jskfan

ASKER

<<<net group "groupname" "Domain Admins" /add >NUL  >>> this might add a group "Domain Admins" to another group, how do I make it add members of a group to another group?

can you explain this please, what it does?
I am getting error "Network path not found"
set group = GetObject(adsPath)

this gives me error
strGroupName = trim(cstr(inputbox("enter domain/group...")))
If trim(strGroupName) = "" Then WScript.quit
adsPath = "WinNT://" & strGroupName & ",group"
set group = GetObject(adsPath)
set d = createobject("scripting.dictionary")
d(d.count) = "" 
d(d.count) = group.adspath
d(d.count) = "" 
For Each member in group.members
 d(d.count) = member.adspath
Next 'Group
wscript.echo join(d.items,vbcrlf
Avatar of jskfan

ASKER

I am running this script, but it gives me an error " the server is unwilling to process the request" line 7 char 1,

which is this line :
objNewGroup.SetInfo


Const ADS_GROUP_TYPE_GLOBAL_GROUP = &H2
Set objOU = GetObject("LDAP://OU=testou, dc=training")
Set objOldGroup = GetObject("LDAP://CN=grouptest1, ou=testou, dc=training")
Set objNewGroup = objOU.Create("Group", "Finance Department")
objNewGroup.sAMAccountName = "financedept"
objNewGroup.groupType = ADS_GROUP_TYPE_GLOBAL_GROUP
objNewGroup.SetInfo

For Each objUser in objOldGroup.Member
    objNewGroup.Add "LDAP://" & objUser
Next



Avatar of jskfan

ASKER

Any update guys?
hi,

Sorry for delay

the server is unwilling to process the request
solution:

http://computerperformance.co.uk/Logon/code/code_80072035.htm