I have a request to remove 100s of sitegroups, so I am simply using powershell to loop through the list of groups and remove the groups. The issue is that this is veerrrrrry slow, it is taking minutes to remove some groups, and completely hanging on others. Does anyone know how to speed this up, or why it is so slow?. I have searched the deep webs looking for a solution. Any help or suggestion is appreciated.

I should note that some of these groups were likely created in a subsite, however I am doing the delete from the root collection.



function Remove-SPGroup (
    [string]$group) {

    $spWeb = $web.Read();
    write-host "Deleting:" $group ...;

$web = Get-SPWeb $WebUrl;
$groups = Get-Content $GroupFile;

ForEach ( $group in $groups ) {
    $spGrp = $web.SiteGroups[$group];
    if ( $spGrp -ne $null ) {
        Remove-SPGroup $web $group;
        $spGrp = $null;

Script is run in a powershell session as the farm admin like so:

.\Rem-Groups.ps1 -w http://mycollection.mydomain.ca -gf C:\scripts\temp\grouplist.txt
  • 1
    I would assume it is because it might be scanning in the background any ACL changes that need to be done by deleting the group throughout the entirety of the site collection, which could time time consuming if the site is large or there are a lot of unique permissions throughout the site. Also, it doesn't matter where the groups were created, they only exist at the root of the site collection. – Eric Alexander Feb 6 '17 at 14:36
  • Thanks Eric, I did see some reference to this, but it was never mentioned that it would take so long. This particular site does have a lot of broken inheritance too, I assume that might increase the scanning time. Do you know if there is any option to disable the ACL scanning? – AMadKinnon Feb 6 '17 at 14:42
  • 1
    Doubtful, I would assume the nature of the commandlet is to 1) find all instances where this group is used 2) remove the group permission on that object 3) finally delete the group from the site – Eric Alexander Feb 6 '17 at 14:45

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.