Bulk Group Membership Addition

This script adds multiple users to an Active Directory group based on a list of usernames in a text file (usernames.txt).

# Define the group name and the file with user list
$groupName = "YourADGroupName"
$userList = Get-Content -Path "C:\Path\To\usernames.txt"

foreach ($username in $userList) {
    Add-ADGroupMember -Identity $groupName -Members $username
    Write-Output "Added $username to group $groupName"
}

• Update $groupName with the name of the group you want to add users to, and change the path of usernames.txt.

• Explanation: This script reads usernames from a file and adds each one to the specified AD group.

Last updated