Enumerate web applications on a sharepoint farm

by James Mann 3/11/2008
To enumerate site collections on a farm:
SPWebService contentService = SPWebService.ContentService;

foreach(SPWebApplication app in contentService.WebApplications) 
{
  if (app.Sites.Count > 0) 
  {
    // pick the first site (root site)
    SPSite rootSite = app.Sites[0];
    
    Trace.WriteLine(site.Url);
  }
}

| To the top |

March 9. 2013 16:26

Leonel Benton

The following is without doubt one of the most interesting posts I have read in  a while.  I would really like to read and find out more about this.

Leonel Benton

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading