我正在尝试从我的 IIS 服务中获取所有网站,但我需要通过 wmic 来完成。
在 Powershell 中,我可以执行
get-website
,结果格式如下,足以满足我的需求,但我无法在 wmic 命令中转换它。
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
我searchforsomeoptions,但任何帮助我。以下是我最后的尝试:
wmic service where name = 'W3svc' call get-website
get - 无效的别名动词。
wmic PATH Win32_ServerFeatrure
2 Web Server (IIS) 0
我可以得到服务,但我不能调用任何命令。
get-wmiobject -query "select * from Win32_Service where name='W3svc'"
第二个选项同样的问题,我可以得到服务,但无法得到任何其他信息。
背景:
我正在为 wmic 使用 Linux 客户端,我需要在 Windows Server 机器上进行连接以获取有关在 Web 服务器中配置的所有网站(活动或非活动)的信息。
有没有办法使用任何 wmic 命令或 WQL 查询来实现它?
原始问题说 powershell 不是一个选项,但其中一个尝试使用 get-wmiobject。
所以为了其他人试图找到这个,这里有一些可能性:
import-module WebAdministration
get-childitem IIS:\Sites\
这也适用于查找应用程序池:
get-childitem IIS:\AppPools\
然后通过该位置可以使用许多属性和方法,而不是通过以下方式找到相同的对象:
get-wmiobject -namespace "root\WebAdministration" -class "Application"
希望这可以帮助其他人。