Listing Application Pools in IIS

I am wondering if there is a way to list a set of application pools (not the applications in this pool, but the pools themselves) on the local IIS server using ASP.net 3.5 without using WMI, and if so can anyone provide a link or an example like this is being done?

(I forgot to add IIS 6.0).

+5
c # iis application-pool iis-6
source share
2 answers

This should help:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.DirectoryServices; namespace AppPoolEnum { class Program { static void Main(string[] args) { DirectoryEntries appPools = new DirectoryEntry("IIS://localhost/W3SVC/AppPools").Children; foreach (DirectoryEntry appPool in appPools) { Console.WriteLine(appPool.Name); } } } } 

I must also add that this will not work in partial trust.

+4
source share

Another way that may be helpful.

 using System.IO; using Microsoft.Web.Administration; namespace AppPoolEnum { class Program { static void Main(string[] args) { foreach (var appPool in new ServerManager().ApplicationPools) { Console.WriteLine(appPool.Name); } } } } 
+2
source share

All Articles