2

I'm trying to code an application that will be able to see the IIS pools remotely, reset, start and stop each pools separately. I'm using the ServerManager (assemblyref://Microsoft.Web.Administration) class.

My problem is the pools name I see are different from the inetmgr grid and there are a different number of them too.

I suppose there must be a lot of things I didn't understand well.

Thanks in advance.

Here is my code:

 public static List<string> GetPools(
            string serverName)
        {
            using (ServerManager mgr =
               ServerManager.OpenRemote(
               serverName))
            {                 
                return mgr.ApplicationPools.Select(n => n.Name).ToList();
            }
        }

![enter image description here][1] enter image description here

MirlvsMaximvs
  • 1,453
  • 1
  • 24
  • 34
  • I think they are the IIS Express app pools, is it listing your dev IIS express setup and not full IIS? – ajg Jun 17 '14 at 16:00
  • In the openremote(serverName) command i just specify my computer name. how can i specify a specific iis instalation of my machine? – MirlvsMaximvs Jun 18 '14 at 06:37
  • looks like there is an answer here http://stackoverflow.com/questions/8467908/how-to-use-servermanager-to-read-iis-sites-not-iis-express-from-class-library – ajg Jun 18 '14 at 10:46

2 Answers2

0

Have you considered not asking for just a list of names?

Select(n => n.Name).ToList();

selects only the name. Now, 10 seconds google leads me to the documentation at

http://msdn.microsoft.com/en-us/library/microsoft.web.administration.applicationpool(v=vs.90).aspx

which indicates the class has a STATE property. Which is an enumeration, which contains the followingvalues:

Valid values are Starting, Started, Stopping, Stopped, and Unknown.

My problem is the pools name I see are different from the inetmgr grid and there are a different number of them too.

Which would be a super strong indicator you compare apples to oranges. Or - the pools on TWO DIFFERENT INSTALLATIONS. IIS Express is a solution for example.

TomTom
  • 61,059
  • 10
  • 88
  • 148
  • Sorry men, i don't know if i understand you. do you say the pools name i listed are from another iis instalation (like the express or visual server) – MirlvsMaximvs Jun 18 '14 at 06:11
0

I don't know enought about why but when i specified the IP instead the machine name it worked(different iis instalation i suppose). Moreover i dont know if i will need impersonation in order to connect to different iis machine.

MirlvsMaximvs
  • 1,453
  • 1
  • 24
  • 34