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

WMI query for web site description


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.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        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/%'")
        Dim wmiSites As Object
        wmiSites = wmiService.ExecQuery("SELECT * FROM IIsWebVirtualDirSetting") ', , 48)
        Dim objItem As Object
        For Each objItem In wmiSites
            Debug.Print(objItem.AppFriendlyName & " = ")

Open in new window

1 Solution
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

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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