I'm looking to delete bulk (300+) Site groups (limited access users) that exist in a site. Powershell seems to be the fastest option, however I'm not great with it and I'm looking to have a script that doesnt delete all groups.
I want the Powershell script to delete all groups except for those which I specify... e.g. loop through all site groups and delete them all, except the groups I specify "My Group Name", "Restricted Readers", etc.
I found a sample script below where you have to specify which groups you want delete.. I want the opposite of this, where I can delete all groups except a set of groups with a certain name..
Example script
$spWeb = Get-SPWeb "https://mysite"
$spGroups = $spWeb.SiteGroups
$groups = ("Group 1", "Group 2","Group 3","Group 4","Group 5","Group 6")
ForEach($group in $groups) {
$spGroups.Remove($group)
}
$spWeb.Dispose()
Edit: I want to delete the application of these groups to the site, e.g. what is achieved when you select the group and click "Remove User Permissions" in the UI