2

Can someone help me with a powershell or C# code to do a Bulk delete of groups on a SharePoint site? I already know about this code:

$site = Get-SPweb "http://root/locations/site"
foreach($group in $site.Groups)
  {
      if ($group.Name.Contains("Records Center Web Service Submitters"))
           {
              $site.SiteGroups.Remove($group.Name)
           }
  }
$site.Dispose()

But unfortunately since I have to delete over 6000 of these from our small sites, and over 60,000 from our largest site, it takes about 9 minutes PER delete, and prevents users from accessing the site while the delete is happening.

I need a way to tell SharePoint to delete them in batches so that the database locks are removing more records at once.

I am also OK if its possible to delete ALL groups, then add back in the groups I want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.