How to clear group membership with Powershell
Something I often recommend to my customers is keep the membership of the Enterprise Admins and Schema Admins groups empty and only populate them (temporarily) when required. The privileges assigned to these groups are obviously high and removing the members reduces the potential for costly mistakes and/or compromise.
Here’s a quick Powershell snippet that will perform the removal:
$grps = "Enterprise Admins", "Schema Admins"
foreach ($grp in $grps) {
Get-ADGroupMember -Identity $grp `
| %{Remove-ADGroupMember -Identity $grp -Members $_ -Confirm:$false}
}
This is something that you could consider running as a scheduled task to ensure the memberships are kept clear.

Comments(0)