Removing Users and Computers from a Group

To remove a user from a group, use the Remove-ADGroupMember cmdlet:

Remove-ADGroupMember -Identity Quality -Members J.Robinson

To remove a computer account from a group, specify the computer name with a dollar sign ($) at the end as the value for the -Members parameter.

Removing Multiple Users from a CSV File

An easy way to remove multiple users from an AD group is to create a CSV file with the list of usernames and then remove those users from the group object using this script:

Import-CSV C:\scripts\users.csv -Header users | ForEach-Object {
  Remove-ADGroupMember -Identity "Quality" -members $_.users
}

Removing a User from All Groups

To remove a user from all groups, run this script:

Get-ADUser -Identity E.Franklin -Properties MemberOf | ForEach-Object {
  $_.MemberOf | Remove-ADGroupMember -Members $_.DistinguishedName -Confirm:$false
}

Removing a User from All Groups

Note that the user will lose all group membership except Domain Users, which can be removed manually if needed.

:warning: Don’t forget to enable the Active Directory Recycle Bin feature so you can easily roll back your changes if something goes wrong.