• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 438
  • Last Modified:

WMI query for web site description

Hi!


I need some VB code to be able to extract from my IIS metabase the web site descriptions. Currently I am using the IIsWebVirtualDirSetting class. I can't seem to find the website description property. The end goal is to iterate trough all my sites on the local server and find all the web site descriptions AS DISPLAYED IN THE IIS WEB SITE PROPERTIES, WEB SITE TAB, DESCRIPTION field.

Thanks!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'hourglass
        System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
 
        Dim network As Object
        Dim sw As New StreamWriter(txtPath.Text)
        blnStop = False
        network = CreateObject("WScript.Network")
 
 
        'app pool plus housekeeping
        Dim wmiService As Object, strComputer As String, locatorObj As Object
        strComputer = "."
 
        locatorObj = CreateObject("WbemScripting.SWbemLocator")
        wmiService = locatorObj.ConnectServer(strComputer, "root/MicrosoftIISv2")
 
        Dim applicationPools As Object
 
        applicationPools = wmiService.ExecQuery("Select * From IIsApplicationPool " & _
            "Where Name LIKE 'W3SVC/AppPools/%'")
 
 
 
        'Sites
        Dim wmiSites As Object
 
        wmiSites = wmiService.ExecQuery("SELECT * FROM IIsWebVirtualDirSetting") ', , 48)
 
        Dim objItem As Object
        For Each objItem In wmiSites
            Debug.Print(objItem.AppFriendlyName & " = ")
        Next

Open in new window

0
yommm
Asked:
yommm
1 Solution
 
jhchoeCommented:
Try this code.
Set objWMIService = GetObject("winmgmts:\\.\root\MicrosoftIISv2") 
Set colItems = objWMIService.ExecQuery("SELECT * FROM IIsWebServerSetting") 
For Each objItem in colItems 
   MsgBox "ServerComment: " & objItem.ServerComment
Next

Open in new window

0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now