0

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?

James
  • 1,653
  • 2
  • 31
  • 60
  • 1
    IIS WMI support should be considered obsolete. You should try to use PowerShell Core as it runs cross platform, https://learn.microsoft.com/en-us/powershell/scripting/core-powershell/ssh-remoting-in-powershell-core?view=powershell-6 – Lex Li Jun 27 '18 at 21:42
  • Thanks for your comment @LexLi. For this project, powershell is not a option at this moment. Do you know any other options instead WMI and Powershell? – James Jun 28 '18 at 01:03

1 Answers1

1

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.

adamt8
  • 308
  • 1
  • 7
  • I don't remember how I solved this problem 5 years ago, but I think I used something in Powershell at the end. I didn't post my solution here at that time precisely because I was looking for something PS-independent, but your solution is the best fit anyway. – James May 01 '23 at 14:15