1

How to I get a list of all SPIisWebServiceApplicationPool on my current farm? There is a powershell command that can do this named Get-SPServiceApplicationPool but I want to get the list in a C# application without using a PowerShell object.

1

Try following: You can modify according to your need and name any service which is by default present in Each webaplication.

foreach (SPService service in SPFarm.Local.Services)
{
    if (service.Name.Equals("ServiceName"))
    {
        foreach (SPServiceApplication serviceApp in service.Applications)
        {
            SPIisWebServiceApplication webServiceApp = (SPIisWebServiceApplication) serviceApp;
            SPIisWebServiceApplicationPool appPool = webServiceApp.ApplicationPool;
        }
    }
}
  • The problem with this is that it gets all the used application pools. I need all the avalible appolication pools. – dburner May 22 '14 at 11:14
  • You mean all application pools that sharepoint sites are not using? Or somthing else? – Aanchal May 22 '14 at 11:15
  • I need a list of all the application pools available to create a new Service Application. For example when you create a new service application you can select use existing application pool. I need all the pools from that combobox. The exact list that Get-SPServiceApplicationPool returns without any parameters. – dburner May 22 '14 at 11:19
0
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);
            }
        }
    }
}

Source: https://stackoverflow.com/questions/1400464/enumerating-application-pools-in-iis

  • This dosent work. There are some pools that are displayed in Sharepoint but are not displayed in IIS (or using your code). – dburner May 22 '14 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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