Tuesday, November 1, 2011

Move users from one group to another

Useful if you are cleaning AD. Note this overwrites the group members inside the dsmod with those members in the dsget part.

if you would like to combine two groups, use -addmbr instead of -chmbr, but this will fail if any users are present in both groups.


C:\WINDOWS\system32>dsget group "CN=redundant - group,OU=Groups,OU=someplace,DC
=childdomain,DC=domain,DC=suffix" -members | dsmod group "CN=original-group,OU=Group
s,OU=someplace,DC=childdomain,DC=domain,DC=suffix" -chmbr

I then deleted the "redundant - group", because it was redundant and used ugly spaces.

One good way to get the Distinguished Name of a group is with

dsquery group -name "groupname"

and then you just copy paste into the command.

easier, faster and better than using vbs's since it has no size restriction.

No comments:

Post a Comment