Trying to remove user from all groups in an Active Directory using PowerShell script

Question:

I’m trying to use a PowerShell script to accept input from the user based on what user they want removed from all groups. Is my syntax wrong? Here’s what I have so far.

Where CISCOVPN and FS-001 are two of the groups I want $User1 removed from. Is there a way to just say remove from all groups?

Answer:

Pipe the groups into Remove-ADGroupMember in a ForEach-Object loop:

Source:

Trying to remove user from all groups in an Active Directory using PowerShell script by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply