Powershell: How to Remove Active Directory Group from a list of AD users

You can use below code to remove an AD group from the list of users specified in upnlist.txt file. Create a text file and add users UPN Names in it. You can modify the script to use user’s samAccount as well if you have users SAM Account Names instead of UPN Names.


upnlist.text file


Update the <GroupName> to the AD Group which you want to remove from the users AD Group membership.

Best Practice: Test the script on one or two test users before running it all the users in your upnlist text file.

Download below script from Microsoft TechNet Gallery






Leave a Reply

Your email address will not be published. Required fields are marked *