No module Published on Offcanvas position

Mass adding users to single Security Group with Powershell

Tired or just too lazy to type and add a bunch of users to a security group?
Powershell makes this super easy to do!

To add a single user to a group, you can use this simple command:
Add-ADGroupMember -Identity (groupname) -Members (username)
Simple right? Except you came here to add multiple users in a single click! This just makes you keep typing the lines over and over again, imagine if you had 100 users!

To do this you will need the following things:

  1. A .csv file with all the users you want added
  2. Basic knowledge of foreach loops

What you want to do is import the .csv file and have Powershell go through each line repeating the Add-ADGroupmember command.

This is an extremely simple way to do it:

$importfile = Get-Content C:\myfile.csv

foreach ($user in $importfile) {
       Add-ADGroupMember -Identity "Domain Admins" -Members $user


This simple command adds all the users in your .csv file to the Domain Admins group. Easy right?
For an example of a working piece of script, find it on my Github here.

To give you a summary of the script. Instead of hardcoding a path for the .csv file, i just make Powershell ask you, this will make powershell create a popup with the all familiar Explorer window where you can select your file.
For my own sanity, I've added logging, that writes a file to the desktop of the user that is running it. I just want to know which user has been added or not and if not for what reason.