AD PowerShell script to add/remove a list of users from a group
Have you ever had to do something manually and you were just like, I don't ever want to do that again it took to long. Well that happened to me when I was setting up my domain and experimenting, I had to keep adding and removing my mock users to groups and it got really annoying. So I simply automated it using PowerShell, know all I need to do is supply a list of the users I want to remove or add and the group name then voila. To automate this I simply went through each line in the CSV file and got the distinguished name of the user using Get-ADUser. I then used either Add-ADGroupMember or Remove-ADGroupMember to add or remove the user, all that needed to be supplied here was the distinguished name of the group and the previously gotten distinguished name of the user. Below is a screenshot of my code, I am happy for you to use it but I am not accountable if you edit or misuse and cause any issues. Screenshot of the code: Results of running the code: