SPServer.SPWebApplications extension method

Just a quick extension method to obtain an IEnumerable of SPWebApplications for a given SPServer.
Language:
C#
Keywords:
SharePoint
Code Snippet

using Microsoft.SharePoint.Administration;

 

public static IEnumerable<SPWebApplication> WebApplications(this SPServer Server)
{
    return Server.ServiceInstances
                 .OfType<SPWebServiceInstance>()
                 .Select(wsi => wsi.Service as SPWebService)
                 .SelectMany(ws => ws.WebApplications);
}


Created 2012-01-25
comments powered by Disqus
Login