December 23, 2024

Powershell Script to remove users from AD Groups in Bulk

1 min read

Below is a really quick script than can save you a ton of time removing users from AD Groups

# Import the Active Directory module
Import-Module ActiveDirectory

# Get the path to the text file containing the list of users
$usersFile = "C:\Users\username\Desktop\users.txt"

# Open the text file and read the list of users
$users = Get-Content $usersFile

# Remove each user from the Active Directory group
foreach ($user in $users) {
    Remove-ADGroupMember -Identity "Group Name" -Members $user
}

# Write a message to the console indicating that the operation was successful
Write-Host "Successfully removed users from Active Directory group."

More Stories

Leave a Reply

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