Just like we added AD users in a group with the help of Ad-ADGroupMember PowerShell cmdlet, we can also remove AD users from a group using PowerShell.
Remove AD Members from Group Using PowerShell
1. Open PowerShell with elevated privileges.
2. Execute the following cmdlet if you would like to remove a single or multiple users (in this case WilsonPais, administrator) suppose from DocumentReaders group.
Remove-ADGroupMember -Identity "DocumentReaders" -Member "WilsonPais","administrator"
3. Execute the following piped cmdlet if you would like to remove multiple users in an OU (suppose Students) from DocuementReader group.
Get-ADUser -SearchBase ‘OU=Students,DC=yourdomain,DC=com’ -Filter * | ForEach-Object {Remove-ADGroupMember -Identity ‘DocumentReaders’ -Members $_ -Confirm:$false }
References
- https://technet.microsoft.com/en-us/library/ee617210.aspx
- https://technet.microsoft.com/en-us/library/ee617242.aspx
- http://www.oxfordsbsguy.com/2015/03/09/powershell-how-to-add-all-users-in-an-ou-to-a-security-group-using-get-aduser-and-add-adgroupmember/