Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Please refer following link for getting objects using "root\WebAdministration" namespace used by IIS7 in windows 2008: <a href="http://discovery.bmc.com/confluence/display/Configipedia/Microsoft+Internet+Information+Services" rel="nofollow">http://discovery.bmc.com/confluence/display/Configipedia/Microsoft+Internet+Information+Services</a></p> <h2>Code for checking website and app pool status on Windows 2008 server using WMI:</h2> <pre><code>Public Sub WebsiteAppPoolStatusCheckIISv7(ByVal computer As String, ByVal userName As String, ByVal password As String) Dim thisServer = System.Configuration.ConfigurationManager.AppSettings("ThisServer") Dim excludedWebSiteOrAppPool = System.Configuration.ConfigurationManager.AppSettings("ExcludedWebSiteOrAppPool") Dim WbemAuthenticationLevelPktPrivacy = 6 Dim objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") Dim objWMIService As Object If (computer = thisServer) Then objWMIService = objSWbemLocator.ConnectServer(computer, "root/WebAdministration") Else 'for remote servers objSWbemLocator.Security_.AuthenticationLevel = WbemAuthenticationLevelPktPrivacy objWMIService = objSWbemLocator.ConnectServer(computer, "root/WebAdministration", userName, password) End If 'Code Start for Website status check Dim websites = objWMIService.ExecQuery("SELECT * FROM Site") For Each website As WbemScripting.SWbemObject In websites Dim WebSiteName = website.Name Dim webSiteStatus As String If (Convert.IsDBNull(website.GetState)) Then webSiteStatus = "Unknown" Else Select Case website.GetState Case 0 webSiteStatus = "Starting" Case 1 webSiteStatus = "Running" Case 2 webSiteStatus = "Stopping" Case 3 webSiteStatus = "Stopped" Case Else webSiteStatus = "Unknown" End Select End If logFile.writeline("Server:= " &amp; computer &amp; ", WebSiteName:= " &amp; WebSiteName &amp; ", Status:= " &amp; webSiteStatus) Next 'Code Start for App pool status check Dim appPools As WbemScripting.SWbemObjectSet appPools = objWMIService.ExecQuery("Select * from ApplicationPool") 'Iterate all the appPools of the server For Each appPool As WbemScripting.SWbemObject In appPools Dim appPoolName = appPool.Name Dim appPoolStatus As String If (Convert.IsDBNull(appPool.GetState)) Then appPoolStatus = "Unknown" Else Select Case appPool.GetState Case 0 appPoolStatus = "Starting" Case 1 appPoolStatus = "Running" Case 2 appPoolStatus = "Stopping" Case 3 appPoolStatus = "Stopped" Case Else appPoolStatus = "Unknown" End Select End If logFile.writeline("Server:= " &amp; computer &amp; ", AppPoolName:= " &amp; appPoolName &amp; ", Status:= " &amp; appPoolStatus) Next End Sub </code></pre> <hr>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload