string pool = "W3SVC/AppPools/";
List<string> result = newList<string>();
ConnectionOptions co = newConnectionOptions();
co.Username =
@"xxx";
co.Password =
@xxx";
co.Authentication =
AuthenticationLevel.PacketPrivacy;
ManagementScope scope = newManagementScope(@"\\" + serverIP/machinename + @"\root\MicrosoftIISV2", co);
ObjectQuery query = newObjectQuery(string.Format("SELECT * FROM IIsApplicationPool"));
ManagementObjectSearcher searcher = newManagementObjectSearcher(scope, query);
foreach (ManagementBaseObject mo in searcher.Get())
{
string name = (string)mo.Properties["Name"].Value;
result.Add(name.Substring(pool.Length));
}