BlakeISS
asked on
Bulk Creating User accounts from csv and adding them to groups
I have an open question regarding this for using ActiveRoles Management Shell but would entertain any method for accomplishing this task. Any good scripts for also adding the users to specified groups?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are all users going to the same groups or different groups for each user?
ASKER
Sorry, I should have indicated that. The users would be going into the same groups.
Cheers,
Joe
Cheers,
Joe
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, I didn't mention that, but it is in the code as was indicated. This is the DN of the new group to add users to:
strNewGroup = "CN=NewUsersGroups,OU=Main Office,OU=Sites," & objRootLDAP.Get("defaultNa mingContex t")
Regards,
Rob.
strNewGroup = "CN=NewUsersGroups,OU=Main
Regards,
Rob.
ASKER
Do you have an example of what the group would look like?
Sure.
Assume your group is named New Users Group, and is in the following OU in ADUC:
domain.com\Sites\Main Office\
You then reverse the OU structure for the LDAP query, and have strNewGroup like so:
strNewGroup = "CN=New Users Group,OU=Main Office,OU=Sites," & objRootLDAP.Get("defaultNa mingContex t")
The defaultNamingContext part takes care of the domain.com specifics, but that translates to DC=domain,DC=com
One note, if the group if you're adding to is located in the *default* Users container in ADUC, then it would be:
strNewGroup = "CN=NewUsersGroups,CN=User s," & objRootLDAP.Get("defaultNa mingContex t")
because for some reason, the default Users container is a "container" rather than an "organization unit", hence the CN= instead of the OU=
Regards,
Rob.
Assume your group is named New Users Group, and is in the following OU in ADUC:
domain.com\Sites\Main Office\
You then reverse the OU structure for the LDAP query, and have strNewGroup like so:
strNewGroup = "CN=New Users Group,OU=Main Office,OU=Sites," & objRootLDAP.Get("defaultNa
The defaultNamingContext part takes care of the domain.com specifics, but that translates to DC=domain,DC=com
One note, if the group if you're adding to is located in the *default* Users container in ADUC, then it would be:
strNewGroup = "CN=NewUsersGroups,CN=User
because for some reason, the default Users container is a "container" rather than an "organization unit", hence the CN= instead of the OU=
Regards,
Rob.
ASKER
In putting together the script with all input, this solution worked. I am going to tweak it in hopes of being able to add in multiple groups.
Thanks Much!
Thanks Much!
Great. Thanks for the grade.
To add more groups, change this:
to this:
and then also change this:
to this:
and that should work fine.
Regards,
Rob.
To add more groups, change this:
strNewGroup = "CN=NewUsersGroups,OU=Main Office,OU=Sites," & objRootLDAP.Get("defaultNamingContext")
to this:
arrNewGroups = Array( _
"CN=NewUsersGroup1,OU=Main Office,OU=Sites," & objRootLDAP.Get("defaultNamingContext"), _
"CN=NewUsersGroup2,OU=Main Office,OU=Sites," & objRootLDAP.Get("defaultNamingContext"), _
"CN=NewUsersGroup3,OU=Main Office,OU=Sites," & objRootLDAP.Get("defaultNamingContext") _
)
and then also change this:
Set objNewGroup = GetObject("LDAP://" & strNewGroup)
objNewGroup.Add(objNewUser.ADsPath)
objNewUser.SetInfo
to this:
For Each strNewGroup In arrNewGroups
Set objNewGroup = GetObject("LDAP://" & strNewGroup)
objNewGroup.Add(objNewUser.ADsPath)
objNewUser.SetInfo
Next
and that should work fine.
Regards,
Rob.
ASKER
This is great but I would also need it to be able to add the users to groups as well.