使用PowerShell查找IIS的版本

Seb*_*ier 20 iis powershell

我希望使用powershell(或WMI)查询找到IIS的版本.

以下是我使用的查询.

Get-WmiObject -namespace "root\microsoftiisv2" -query "select MajorIIsVersionNumber from IISWebInfo"
Run Code Online (Sandbox Code Playgroud)

我在带有'IIS 8'的'Windows 8'PC中使用powershell控制台测试了此查询.但结果是7,其中预期的版本号是8.

有人可以帮我解决这个问题吗?

CB.*_*CB. 25

你可以试试:

get-itemproperty HKLM:\SOFTWARE\Microsoft\InetStp\  | select setupstring,versionstring 
Run Code Online (Sandbox Code Playgroud)


Bas*_*ran 6

即使线程有点旧,这是我首先登陆的链接。所以让你知道我发现了什么。

下面的命令帮助我在 IIS 8.5 (Windows 2012 R2) 和 7.5 Windows 7 SP1 上正确找到了 IIS 版本。

[System.Diagnostics.FileVersionInfo]::GetVersionInfo("$env:SystemRoot\system32\inetsrv\InetMgr.exe").ProductVersion

参考:

https://forums.iis.net/p/1171695/1984536.aspx:来自 f00_beard 的回答