Adding Users and Computers to a Group

You can add users, computers, and even other groups to AD groups with the Add-AdGroupMember cmdlet.

Adding Users to a Group

Single User

Add one user to a group:

Add-AdGroupMember -Identity Quality -Members B.Jackson

Multiple Users

Add two users to the “Quality” group:

Add-AdGroupMember -Identity Quality -Members B.Jackson, E.Franklin

Adding Computer Accounts

To add a computer account to a group, append a dollar sign ($) to the end of the computer account name:

Add-AdGroupMember -Identity Quality -Members WKS043$

Adding to Multiple Groups

Add a user to multiple groups at once:

"Managers","Quality" | Add-ADGroupMember -Members `
  (Read-Host -Prompt "Enter User Name")

You’ll be prompted to input the username.

Verifying Group Membership

Once you’ve added users to a security group, verify they are listed as members:

Get-ADGroupMember -Identity Quality

Output Example

Adding Groups to Other Groups

You can nest groups by specifying a group name as the member:

Add-ADGroupMember -Identity "Managers" -Members "Quality"

This makes the “Quality” group a member of the “Managers” group.

Bulk Operations

Adding Many Users from CSV

If you want to add a large number of users to a group, specify them in a CSV file and then import that file.

CSV Format: The list of usernames in the CSV file must contain the SamAccountNames in the “users” column:

Import Script:

Import-CSV C:\scripts\users.csv -Header users | ForEach-Object {
  Add-AdGroupMember -Identity "Quality" -members $_.users
}

Copying Group Membership

Copy all members from one group to another group:

Get-ADGroupMember "Quality" | Get-ADUser | ForEach-Object {
  Add-ADGroupMember -Identity "QualityControl" -Members $_
}