Hello ManagementObjectEnumerator
I totally didn't know that there was a ManagementObjectEnumerator class, but I found out there was today which made me all sorts of happy. What I was trying to do was to just display a list of the application pools of the current host machine's IIS instance within this small WinForms app I have that performs some warm-up functions for SharePoint. I needed to target application pools because we have a complex recycling theme, and I needed scheduled post-warm up functions. What I ended up doing in order to list them was just this:
-
string l_strClassPath = @"\\" + hostname + @"\root\microsoftiisv2:IIsApplicationPoolSetting";
-
{
-
using (ManagementObjectCollection.ManagementObjectEnumerator l_oMoEnumerator = l_oWmi.GetInstances().GetEnumerator())
-
{
-
while (l_oMoEnumerator.MoveNext())
-
{
-
ManagementObject l_oChildMO = ((ManagementObject)l_oMoEnumerator.Current);
-
char[] l_aSplitChar = "/".ToCharArray();
-
tbApplicationPoolList.Items.Add(l_oChildMO.ToString().Split(l_aSplitChar)[(l_oChildMO.ToString().Split(l_aSplitChar).Length - 1)].Replace("\"", ""));
-
}
-
}
-
}
I like that!
1 Comment »
RSS feed for comments on this post. TrackBack URL





















Articles & Research
SharePoint Architecture
Personal/Off-Topic
Latest Free SharePoint Software
SecureCenter For SharePoint
SharePoint Security Assurance Program™
Free Online SharePoint Security Tools
Online SharePoint Security Health Assessment
Article Or Research Filed Under 
You do realize that lines 4 through 7 can be exactly replaced by:
foreach (ManagementObject l_oChildMo in l_oWmi.GetInstances()) {
?
Comment by Erich Stehr — November 14, 2007 @ 3:48 pm