title: WMI access to IIS7
body: <p>We have an internal tool that enumerates the IIS sites and applications for a server. It uses code similar to this:</p>
  
  <pre><code>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)
      {
          // ...
      }
  }
  </code></pre>
  
  <p>The problem I'm having is that when the <code>Sites</code> 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.</p>
  
  <p>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 <code>SELECT Name from Site</code>). 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 <code>Site</code> and <code>Application</code> objects. I'm using <code>root\WebAdministration</code> for the namespace.</p>
  
  <p>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?</p>