locked
Deleting multiple MOSS groups at once RRS feed

  • Question

  • Is there a script or utility for this? I'm not too good at scripting so step by step instructions will really help. Thanks.
    Wednesday, November 10, 2010 8:58 PM

Answers

  • Hi,

     

    you can work it out by using Object Model. Mainly functional class here is SPGroups. The code shown below is an example of Deleting all cross site groups from the root web of a site collection.

    private void DeleteAllSiteGroups(SPWeb rootWeb)
    {

    SPGroupCollection corssSiteGrps = rootWeb.SiteGroups;
    ArrayList siteGrpsDeleteArray = new ArrayList();
    for (int i = 0; i < corssSiteGrps.Count; i++)
    {
    siteGrpsDeleteArray.Add(corssSiteGrps[i].Name);

    }

    foreach (object item in siteGrpsDeleteArray)
    {
    corssSiteGrps.Remove((string)item);
    }


    }

    You can reference this link: http://msdn.microsoft.com/en-us/library/ms477243.aspx

    I wish you every success in your important work.

    Best regards,

    David HM

    • Marked as answer by Peng Lei Thursday, November 18, 2010 7:48 AM
    Friday, November 12, 2010 1:15 AM

All replies

  • I've not been able to find a script that deals with deleting user groups, but Gary Lapointe has written an STSADM extension that deletes all users from a Site Collection.  Have a look at this: -

    http://stsadm.blogspot.com/2008/08/delete-all-users-from-site-collection.html


    http://www.final-exodus.net
    Thursday, November 11, 2010 11:33 AM
    Answerer
  • Thanks but I need it for groups. In the sharepoint portal users have a checkbox next to them for deletion, but groups don't. I've got over 1000 sharepoint groups to delete and don't want to do them 1 at a time.
    Thursday, November 11, 2010 8:24 PM
  • Hi,

     

    you can work it out by using Object Model. Mainly functional class here is SPGroups. The code shown below is an example of Deleting all cross site groups from the root web of a site collection.

    private void DeleteAllSiteGroups(SPWeb rootWeb)
    {

    SPGroupCollection corssSiteGrps = rootWeb.SiteGroups;
    ArrayList siteGrpsDeleteArray = new ArrayList();
    for (int i = 0; i < corssSiteGrps.Count; i++)
    {
    siteGrpsDeleteArray.Add(corssSiteGrps[i].Name);

    }

    foreach (object item in siteGrpsDeleteArray)
    {
    corssSiteGrps.Remove((string)item);
    }


    }

    You can reference this link: http://msdn.microsoft.com/en-us/library/ms477243.aspx

    I wish you every success in your important work.

    Best regards,

    David HM

    • Marked as answer by Peng Lei Thursday, November 18, 2010 7:48 AM
    Friday, November 12, 2010 1:15 AM