'Using System.Management to retrieve WMI / IIS7 info.
'Define the WMI connection information
Dim options As New System.Management.ConnectionOptions()
'options.Username = strUID
'options.Password = strPWD
'Define the Scope information / Note the path defined.
Dim scope As System.Management.ManagementScope
scope = New System.Management.ManagementScope(\\.\root\WebAdministration)
'Define Query and Searcher objects
Dim WMIQuery As New System.Management.SelectQuery("SELECT * FROM ApplicationPool")
Dim searcher As New System.Management.ManagementObjectSearcher(scope, WMIQuery)
'Connect to WMI
Try
scope.Connect()
Catch ex As Exception
Exit Sub
End Try
'Dim variables for information that will be returned
Dim AppPoolName As System.Management.ManagementObject
Dim col As System.Management.ManagementObjectCollection
'Return the collection
col = searcher.Get()
'Write the list of Application Pools to webpage
For Each AppPoolName In col
Response.Write(AppPoolName.GetPropertyValue("Name").ToString() & "<BR>")
Next
Here is the IIS7'ish way of using the Microsoft.Web.Administration col = Server.ApplicationPools
Dim Server As New Microsoft.Web.Administration.ServerManager
Dim col As ApplicationPoolCollection
Dim x As Integer = 0
For x = 0 To col.Count - 1 col = Server.Sites Dim SiteName As String = ""
AppPoolName = col(x).Name
Next
'Return a list of Sites
Dim Server As New Microsoft.Web.Administration.ServerManager
Dim col As SiteCollection
Dim x As Integer = 0
SiteName = col(x).Name
Next
RSS