Remove Users from all AD Groups

Modified on Thu, 03 Nov 2022 at 09:29 AM

If you are looking for a way to remove users from all groups, in CoreView you can import the following script:

   "id": "2d260602-3ce4-484b-96d5-e08ade0bef3b",
   "title": "Remove all AD group memberships v3",
   "description": "Script will remove all AD group memberships for 1 user",
   "lastModified": "2022-04-22T13:56:44.0380000Z",
   "target": "None",
   "tags": [],
   "vars": [
         "name": "SAMAccountName",
         "type": "string",
         "isRequired": true
   "params": [],
   "columns": {},
   "version": 4,
   "statement": "param ([string]$SAMAccountName)\r\n\r\n$members = Get-ADUser -Identity $SAMAccountName -Properties MemberOf\n\n    foreach( $group in $members.MemberOf){\n        Remove-ADGroupMember -identity $group -Members $SAMAccountName -Confirm:$false\n\n    }"

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article