Is it possible to move users from one security group to another?

Home Forums Scripting PowerShell Is it possible to move users from one security group to another?

This topic contains 2 replies, has 3 voices, and was last updated by Avatar Anonymous 3 years, 1 month ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • Avatar
    jason0923
    Participant
    #166641

    I’m looking to see if I can automate moving users between OU’s and security groups with Powershell. So we have an OU for each building and security groups all named something like buildA users and buildb users. I’m looking to see if I can script something like move user X where from A to B where it would see they are in group buildA move them to group buildb. IS that even possible

    Avatar
    Ossian
    Moderator
    #191401

    Yes, I would think so
    How will the script pick up which building they are in – AD properties?

    Something like
    for each user
    If building property = B
    if group = A
    then remove from group A and Add to Group B
    next user

    Let me know if that’s roughly what you are thinking and I will try to come up with something more power-shelly

    Avatar
    Anonymous
    #371968

    The thing to remember about users and groups is that you don’t add/delete a user’s group membership from the user’s point of view with Powershell, You remove the user from Group A’s member list and then add them to Group B’s member list. Even tho the ADUC GUI makes it look that way when viewing a user’s ‘Member of’ tab, the PS commands are all focused around manipulation of the membership of the Group object from the Group’s point of view. Sounds a little backward but it works.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.