Question

We have an internal tool that enumerates the IIS sites and applications for a server. It uses code similar to this:

using (var serverManager = ServerManager.OpenRemote(serverName))
{
    var site = serverManager.Sites[siteName]; // This is slow

    // And just starting to enumerate Applications is incredibly slow
    foreach (var application in site.Applications)
    {
        // ...
    }
}

The problem I'm having is that when the Sites collection is accessed, the response time is really slow when connecting to a server over our VPN. Accessing the applications for a site is even slower. My theory is that the slowness is caused by the fact that the entire set of metadata for the sites is probably sent over the wire. However, I only need a subset of the site data.

My theory is that if I switched the code to using WMI queries, I'd be able to query for only the specific fields that concern this application (like SELECT Name from Site). Unfortunately, when trying to explore WMI objects in WMI CIM Studio, even for my local IIS 7.5, none of the objects I'd expect to be present, like Site and Application objects. I'm using root\WebAdministration for the namespace.

Does any of this WMI stuff work for IIS 7.5? I ensured that the "IIS 6 WMI Compatibility" is turned on. Are there any alternative lightweight ways to query the metadata for an IIS instance?

Was it helpful?

Solution

  1. You can manage IIS 7.5 via WMI and the simplest WQL query SELECT Name from Site will output the list of available sites. See "Managing Sites with IIS 7.0's WMI Provider".

    Note: if you intend to use scripts for IIS6, you may be required to rewrite them. Most scripts for IIS6 won't work with IIS7 because methods in WMI provider of IIS 6 and IIS7 are different.

  2. You can start CIM Studio this way:

    1. Share C:\Program Files (x86)\WMI Tools on your network and set Read / Write access for your account to the share.
    2. Start IE and enter \\hostname\WMI Tools\studio.htm URL.
  3. If you still can't start WMI Studio, use wbemtest tool to explore root\WebAdministration namespace.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top