Remove AD Group Membership for a list of AD User Objects
The below powershell script takes a list of AD user accounts (samaccountname) and removes the AD group membership for each individual user. -Confirm:$false removes the confirmation prompts that normally occur for each membership deletion. Note, the user will not be removed from their primary group.foreach ($user in (get-content c:\users.txt))
{
foreach ($g in (get-aduser -identity $user -properties memberof).memberof)
{
remove-adgroupmember -identity $g -member $user -Confirm:$false
}
}