IIS
  Home arrow IIS arrow Page 4 - IIS 6.0, Getting Information Using WMI
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
IIS

IIS 6.0, Getting Information Using WMI
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 31
    2005-10-12

    Table of Contents:
  • IIS 6.0, Getting Information Using WMI
  • What is new in IIS 6.0?
  • Can we retrieve IIS information using WMI?
  • Playing with Virtual directories and Web applications
  • How about SMTP, POP3, FTP services in IIS?

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    IIS 6.0, Getting Information Using WMI - Playing with Virtual directories and Web applications
    (Page 4 of 5 )

    Let us consider that I would like to retrieve all Virtual directories existing in my local IIS web server.  You can simply use the following WMI script and get it executed through WSH at the command prompt:

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftIISv2")
    Set colItems = objWMIService.ExecQuery( _
        "SELECT * FROM IIsWebVirtualDir",,48)
    For Each objItem in colItems
        Wscript.Echo objItem.AppRootEcho & " --> " & objItem.Name
    Next

    Within the above example, I am working with a class “IIsWebVirtualDir” available in  the “\\root\MicrosoftIISv2” namespace.  “IIsWebVirtualDir” mainly contains all directories, which are termed Virtual Directories.  You can get plenty of other information using the same class.

    If we wanted to know which web applications are currently running, along with their responsible application pools (as explained in second section), we can use the following script:

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftIISv2")
    Set colItems = objWMIService.ExecQuery( _
        "SELECT * FROM IIsWebVirtualDirSetting",,48)
    For Each objItem in colItems
        Wscript.Echo "Name: " & objItem.Name & " -> Pool: " & objItem.AppPoolId
    Next

    Within the above example, I am working with a class “IIsWebVirtualDirSetting” available in the “\\root\MicrosoftIISv2” namespace.  “IIsWebVirtualDirSetting” gets all the web settings or IIS settings for each and every Virtual Directory available in “IIsWebVirtualDir”.  The next example is also based on the same class.

    If you wanted to check and see all the virtual directories allowed with directory access, you have the following script:

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftIISv2")
    Set colItems = objWMIService.ExecQuery( _
        "SELECT * FROM IIsWebVirtualDirSetting",,48)
    For Each objItem in colItems
            Wscript.Echo "Name: " & objItem.Name
     & " -> browsing Enabled: " & objItem.EnableDirBrowsing
    Next

    More IIS Articles
    More By Jagadish Chaterjee


       · Hey guys, the power of WMI with IIS6 is here...have some good suggetions?...do not...
     

    IIS ARTICLES

    - Retrieving IIS information using ASP.NET 2.0
    - IIS 6.0, Getting Information Using WMI
    - The Importance of a Domain
    - Implementing a PKI, Part II: Configuring IIS...
    - Creating Test and Production Sites with Only...
    - Authentication and Authorization
    - Beefing Up IIS: 10 Tips From A Former Solari...
    - An Introduction To ISAPI
    - Secure Your Web Server With SSL
    - Introduction to HTML and ASP
    - Instructions to help in Designing your own C...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway