SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an SPGroup object populated, how can I remove all members from the group, so that essentially I start with a fresh group.

I can't delete and recreate it, so I need a way to work with the existing SharePoint group.

Thanks in advance

share|improve this question
up vote 9 down vote accepted

Take a look on msdn

    foreach (SPUser user in group.Users)

But be aware that you change this group for the whole site collection, if you have other site collections those won't be impacted by the modification of this group.

share|improve this answer
Won't this throw a modify collection exception? – JL01 Sep 16 '11 at 11:55
I have tested it and it works. – Anatoly Mironov Sep 16 '11 at 12:18
Neat, was looking for this. I was afraid that this would in fact skip every other user due to the indexes changing as users get removed, as is the situation when removing groups for example. Tried it, and it worked fine. Nice solution Anatoly. =) – Johannes Jan 31 '12 at 16:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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