How to remove a single SPGroup from SiteGroups from my SiteCollection using PowerShell.When I tried my code I am getting collection was modified error. Lets say the group name is "Group1" and I want to extract this group name using the sitegroups method of site's rootweb and delete the same.

  • Are you trying to remove custom site groups? or the OOB ones – Asad Refai Apr 29 '15 at 9:40
  • @Asad, Thanks. Am trying to remove the one of the custom groups which is created by me.The name of the group is say "Group1". I have some 600+ SPGroups created and I want to delete this Group1 for a particular reason. – userAZLogicApps Apr 29 '15 at 9:45
$spWeb = Get-SPWeb "https://spdev"
$GroupName="Group 1"

if($spWeb.SiteGroups[$GroupName] -ne $null)
Write-Host "Group Deleted!"
Write-Host "Group doesn’t Exists!"
| improve this answer | |

You can do this using

$web = Get-SPWeb "http://siteurl"
$groups = $web.SiteGroups

$g = ("Group1")

ForEach($group in $g) {

| improve this answer | |
  • Never foreach while deleting or removing.. – George Norberg Sep 15 '16 at 13:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.