An Active Directory group can have one or more members, service accounts, groups, or machines removed using the PowerShell “Remove-ADGroupMember” cmdlet. The stated cmdlet uses the “-identity” parameter to specify the Active Directory group that contains the users who need to be removed.
The following article will overview the PowerShell “Remove-ADGroupMember” cmdlet.
How to Use the Remove-ADGroupMember (ActiveDirectory)?
The cmdlet “Remove-ADGroupMember” is responsible for deleting or removing members from an Active Directory group.
Let’s explain the stated cmdlet with the help of provided examples below!
Example 1: Use the “Remove-ADGroupMember” Cmdlet to Remove a Member From a Group
Execute the below-given command to remove a member from a group:
According to the above-provided command:
- First, write the “Remove-ADGroupMember” cmdlet.
- Then, specify the “-Identity” parameter and assign it the group name whose member you want to remove.
- Then, specify the “-Members” parameter and provide it the username to be removed from the group.
Example 2: Use the “Remove-ADGroupMember” Cmdlet to Remove Multiple Members From a Group
To remove multiple users from a specified group, run the following command:
In the above-given command:
- Initially, specify the “Remove-ADGroupMember” cmdlet along with the “-Identity” parameter having the group name assigned to it.
- After that, use the “-Members” parameter and assign it to the two users to be removed separated by a comma.
Example 3: Use the “Remove-ADGroupMember” Cmdlet to Remove a Distinguished User From a Group
In order to remove the distinguished user from a group, execute the below-given command:
According to the above command:
- First, mention the “Get-ADGroup” cmdlet.
- Then, write the “-Server” parameter to provide the server address along with the “-Identity” parameter having the group name assigned to it.
- After that, add the pipeline “|” and the “Remove-ADGroupMember” cmdlet.
- Lastly, specify the “-Member” parameter and assign it the distinguished username.
That was all about the “Remove-ADGroupMember” cmdlet in PowerShell.
Conclusion
The “Remove-ADGroupMember” cmdlet is responsible for removing or deleting users, groups, or service accounts from an Active Directory group. This blog provided a brief explanation of the “Remove-ADGroupMember” with the help of several examples.