Exactly as the title says, an example of how to change the Primary Group for a set of users returned by a search with PowerShell.

1 Comment

  1. Pingback: Working with AD groups in PowerShell - Admins Goodies

  2. Nice script! You can wrap this in a function and change the following two lines to be able to change the Primary Group on a per user basis.

    $BaseOU = [ADSI]”LDAP://$DomainNC”
    $LdapFilter = “(&(objectClass=user)(objectCategory=person)(primaryGroupId=$OldGroupToken)(sAMAccountName=$Member))”

    Cheers,
    Jeremy.

    Reply

  3. Pingback: primaryGroupToken via C# from Active Directory (AD) « Michael Ayvazyan on the Network

  4. Pingback: MS: AD: Defining primary group membership with Powershell | SysAdmin Stuff

Leave a Reply

Your email address will not be published. Required fields are marked *