To be even more specific, here's the code I've tried so far (based on code for a similar question on the forums):
ConnectionOptions co = new ConnectionOptions();
co.Impersonation = ImpersonationLevel.Impersonate;
co.Authentication = AuthenticationLevel.PacketPrivacy;
string objPath = "IISApplicationPool.Name='W3SVC/AppPools/" + "TestPool" + "'";
ManagementScope scope = new ManagementScope(@"\\" + "localhost" + @"\root\MicrosoftIISV2", co);
using (ManagementObject mo = new ManagementObject(objPath))
{
mo.Scope = scope;
object poolState = mo.GetPropertyValue("AppPoolState");
}
This gives an error, saying "Invalid Namespace"... this error does not appear if I delete the 2 lines inside of "using". There must be some flaws there, but none of the other attempts I've made have come this close.