Add Multiple Users to a AD Group

Adding User to a new group is annoying task when the amount of the users that need to be adding is more.

Powershell comes handy for this task with the script below it should be a piece of cake.

Things to note before running the script:

  • Active Directory module needs to be import to Powershell.
  • The Administrator should have relevant access to run the script.

To display the result in the screen.

Import-module ActiveDirectory

$reader = [System.IO.File]::OpenText("list of username.txt")

while($null -ne ($user= $reader.ReadLine())){

    Try{
    Add-ADGroupMember -Identity "Group name" -Member $line
    $user+" has been Added to the group!!"
    }catch{
    $user+ "not added to the group!!!"
    }
}

$reader.Close()

if you need a report of users added to a specific group in a text use the below script.

Import-module ActiveDirectory

$reader = [System.IO.File]::OpenText("list of username.txt")

while($null -ne ($user= $reader.ReadLine())){

    Try{
    Add-ADGroupMember -Identity "Group name" -Member $user
    $user+" has been Added to the group!!"
 >> "Path to save.txt"
    }catch{
    $user+ "not added to the group!!!"
 >> "Path to save.txt"
    }
}

$reader.Close()