iiswebserverwmiwmicwql

Is it possible to get all IIS sites from WMI?


I'm trying to get all websites from my IIS service, but I need to do it through wmic.

In Powershell, I can do a get-website and the results are in the format below, that is good enough for my needs, but I can't convet it in a wmic command.

Name             ID   State      Physical Path                  Bindings
----             --   -----      -------------                  --------
Default Web Site 1    Stopped    %SystemDrive%\inetpub\wwwroot  http *:80:
my.site          2    Started    C:\Users\My/Path               https 127.0.0.0:443: sslFlags=0

I searched for some options, but anything helped me. Below is my last tries:

  1. wmic service where name = 'W3svc' call get-website

get - Invalid alias verb.

  1. wmic PATH Win32_ServerFeatrure

2 Web Server (IIS) 0

I can get the service, but I can't call any command.

  1. get-wmiobject -query "select * from Win32_Service where name='W3svc'"

Same problem of second option, I can get the service, but can't get any other info.

Backgroud:

I'm using a Linux client for wmic and I need to connect in Windows Server machines to get info about all websites (active or not) configured in the web server.

Are there any way to achieve it using any wmic command or WQL query?


Solution

  • Original question says powershell isn't an option, but one of the attempts uses get-wmiobject.

    So for the sake of others trying to find this, here are some possibilities:

    import-module WebAdministration
    get-childitem IIS:\Sites\
    

    this also works for finding application pools:

    get-childitem IIS:\AppPools\
    

    And then there are numerous properties and methods available through that location, than by finding the same object with:

    get-wmiobject -namespace "root\WebAdministration" -class "Application"
    

    Hope this can help anyone else.